How to change Button Label

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
I have an Action button that when clicked changes status.  Now, the button says "Action".  I would like to have a rule or function that would change the Button Label to something more meaningful... like "Change Status to Ordered" or "Change Status to 'In Warehouse'" based on the current status.

Any suggestions on the best way to do that?  Of course, I do not want to permanently change the label value, but have it be dynamic based on the data in the record.

Thanks,
Dean
Photo of Dean

Dean

  • 636 Points 500 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,994 Points 50k badge 2x thumb
Can you post your current code?
Photo of Dean

Dean

  • 636 Points 500 badge 2x thumb
sure... I am using a variation of something you suggested in another post.  btw... the link works to change the data but I don't know how to use the $buttonLabel?

var text nextStatus = 
   Case( [Related status]
   ,13,"16"
   ,16,"14"
);

var text buttonLabel = 
   Case( [Related status]
   ,13,"Update Status 'In Warehouse'"
   ,16,"Update Status 'Ready For Pickup'"
); 


var text URL = URLRoot()
& "db/bn6bxjm9t?a=API_EditRecord&rid=" & [Record ID#]
& "&_fid_23="& $nextStatus  
& "&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4";


If($nextStatus > ""
   , "javascript:" &
      "$.get('" & 
      $URL & 
      "',function(){" &
      "location.reload(true);" &
      "});" 
      & "void(0);"
)
Photo of Dean

Dean

  • 636 Points 500 badge 2x thumb
thanks for the help.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,994 Points 50k badge 2x thumb
I suggest making a copy of the field and then changing the type to formula rich text.

The generic format for a hyperlink is this

" & $Words & ""

The Words can be divined as any text string including HTML or an image. So you can start low tech and make an html string for words

Start with this

var text Words =
Case( [Related status]
,13,"Update Status 'In Warehouse'"
,16,"Update Status 'Ready For Pickup'"
);

But you can add color and bonding and font sizes with basic html.

,13,"Update Status 'In Warehouse'"

If you want to put in more effort, you can also go to a site called

Dabuttonfactory.com

And create a custom image for a button.

There is probably a way to have a string of code which will actually create a button shape image and let you control the words but I don’t have the syntax available for that.

You can also use the stock images which Quick Base provides and combine yhem with Words.

I will post a link separately.
Photo of Dean

Dean

  • 636 Points 500 badge 2x thumb
hmmm... how would that be integrated with button such that when the button is clicked it runs the api_editrecord?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,994 Points 50k badge 2x thumb
Sorry , my post above got garbled by this forum. I will post back later today when I’m back on my computer.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,994 Points 50k badge 2x thumb
OK, let try again,
The site did  not seem to allow me to put in extra spaces between the section of code.  ir after each semi colon.



var text Words = 
   Case( [Related status]
,13,"16"
   ,16,"14"
);
var text Words = 
   Case( [Related status]
   ,13,"<b><font size=+1>Update Status 'In Warehouse'"
   ,16,"<b><font size=+1>Update Status 'Ready For Pickup'"
); 
var text Update = URLRoot()
& "db/bn6bxjm9t?a=API_EditRecord&rid=" & [Record ID#]
& "&_fid_23="& $nextStatus  
& "&apptoken=dwnt9wipc3cvfcg6nvd3ba97ps4";
var text URL = 
    "javascript:" &
      "$.get('" & 
      $Update & 
      "',function(){" &
      "location.reload(true);" &
      "});" 
      & "void(0);";
IF($NextStatus<>"",
"<a href=" & $URL & ">" & $Words & "</a>"
)

Photo of Dean

Dean

  • 636 Points 500 badge 2x thumb
should the field still be a formula url?  I am getting this now.

https://xx.quickbase.com/db/http:/<a href=javascript:$.get('https:/fixandpaint.quickbase.com/db/bn6bxjm9t?a=API_EditRecord&rid=15&_fid_23=16&apptoken=xxx',function(){location.reload(true);});void(0);><b><font size=+1>Update Status 'In Warehouse'</a>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,994 Points 50k badge 2x thumb
The field type should be formula rich text.
Photo of Dean

Dean

  • 636 Points 500 badge 2x thumb
nice.. now it works perfectly.... since I lost the button I will want to get an image like you were suggesting... thank you very much for all the help.  I do not think I could have figured it out.