Button Named after data in a field

  • 1
  • 2
  • Question
  • Updated 1 year ago
  • Answered
I am using a text formula to generate a button and need to do something outside of my skill set. I need the button name to change based on the data in a specific text field. It sounds odd but is actually needed. Here is a sample of the formula.....

// Begin button style
var text bgcolor = "#A5E294";
var text txtcolor = "black";
var text style = "style=\"text-decoration: none;\n\n box-shadow: 3px 3px 1px #888888; \n\n background:" & $bgcolor & ";\n\n border-radius: 3px;\n\n padding: 5px 8px;\n\n color: " & $txtcolor & ";\n\n display: inline-block;\n\n font: bold 700 24px/1 \"Calibri\", sans-serif;\n\n text-align: center;\n\n text-shadow:none;";
// End button style

If([Can work be invoiced?]=false,
"<a " & $style & " href=" &
URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & URLEncode ([Record ID#])
& "&_fid_104=1"
& "&_fid_105=1"
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=q&qid=128")
& ">Add to Billing</a>"
,"")
Photo of Jason

Jason

  • 1,012 Points 1k badge 2x thumb

Posted 1 year ago

  • 1
  • 2
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
Inorder to change the label name you can use API_SetFieldProperties

https://target_domain/db/target_dbid?a=API_SetFieldProperties&fid=6&label=labelchanged&apptoken=app_token
Examples:

target_domain : sampledev.quickbase.com
target_dbid: Table ID [bjhsda32s]
6: Your field id
labelChanged : get the value of the field
app_token: if you made the app token required 
(Edited)
Photo of Jason

Jason

  • 1,012 Points 1k badge 2x thumb
I guess I wasn't clear, I don't want to change the name of the field just the labeling on the button itself.
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
Jason , so you need to change the label of the formula field itself, no problem instead of  6 give the fid of the formula field on the below formula
Photo of Jason

Jason

  • 1,012 Points 1k badge 2x thumb
At the bottom the formula has Add to Billing that is the custom  name added to the button for the user. I want to take a field [Record Name] that would contain a the related name of a field in another table. The data would be June 2016 so I would be able to have button say Add to June 2016 Billing. This would make the label on the button not the field dynamic so that the end users would clearly see what record is the data is applying to.
Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
i think then you can use iol technique and load a script  then you can call the [Record Name] field id value and assign it to the label  name 

sample Code

$("#tdf_2 a").text($("#_fid_11").val());

tdf_2 
is the parent div id for the formula field 
_fid_11: [Record Name] 

Photo of John Thomas

John Thomas

  • 1,062 Points 1k badge 2x thumb
var text value = [LabelName];

If(ToNumber([CheckBox])=1,
URLRoot() & "db/" & Dbid() & "?a=API_SetFieldProperties&rid=" & URLEncode ([Record ID#])
& "&fid=6"& "&label="& $value &" "& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=q&qid=1")
& ">Add to Billing</a>" 
,"")

LabelName: field which you are entering the new value which should be reflected as label name
6: 
instead of this give your fid of the target field which you want to change

I Hope this will solve your issue

Tested Working for me!!
Photo of Jason

Jason

  • 1,012 Points 1k badge 2x thumb
Your information will help with some future work. The final solution I got for the naming was this:
& "> Add to "&[IRF - Record Name]&"</a>"
I kept making formatting mistakes. Thanks for the help and  hopefully one day I can return the help.