Button to edit a field and save record

  • 0
  • 1
  • Question
  • Updated 12 months ago
  • In Progress
I'm trying create a button that will edit a multi-select text field(field id 61) and save the record.
I currently have the button to save the record... Need help adding the edit part....

var text url = URLRoot() & "db/" & [_DBID_TABLE_1] & "?a=dr&dfid=2&rid=" & URLEncode([Route ID#]);

"<a href="& $url &"><img width=\"120\"src=\"https://cokem.quickbase.com/up/bnckjw5jp/g/rc/eg/va/arrowRoute.jpg\"></a>"
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb

Posted 12 months ago

  • 0
  • 1
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,286 Points 5k badge 2x thumb
Hi Chad,

Typically for a button that edits a record and then saves those changes you would want to use the API Edit Record call within your button. The syntax of that would look something like below

URLRoot() & "db/" & [_DBID_TABLE_1] & "?a=API_EditRecord&rid=" & URLEncode([Route ID#])&[Record ID#]&"&apptoken=xxxxxxxxxxxxx
&_fid_21=1
&_fid_15= "Marked for Review"

What this basic format does is calls the API_EditRecord call and using the Route ID# to fill in the rid and then for each field you want to change you need to include &_fid_(field id here)=(Value to be written). So in my example it is marking field 21 as true and making fid 15 equal to Marked for Review. Then you could include any redirect behavior you wanted to see to finish out the button. You would also just need to include an App Token for the application that you are looking to make the changes in.

Alternatively, if you just want to open up the record to be edited by a user and just auto populate a few values you would replace API_EditRecord with the call er (Edit Record Form). 

URLRoot() & "db/" &  [_DBID_TABLE_1] & "?a=er&dfid=2&rid="& URLEncode([Route ID#])&[Record ID#]&"
&_fid_21=1
&_fid_15= "Marked for Review"

This will open the form to be edited and saved by the user with those fields pre populated for them. It just depends on which step you want to automate. 
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb
Trying to work with 

URLRoot() & "db/" &  [_DBID_TABLE_1] & "?a=er&dfid=2&rid="& URLEncode([Route ID#])&[Record ID#]&"
&_fid_61=1

But I get a syntax error that &_fid_61=1 is not a valid expression
Photo of Systems BVI

Systems BVI

  • 530 Points 500 badge 2x thumb
Should be :
URLRoot() & "db/" &  [_DBID_TABLE_1] & "?a=er&dfid=2&rid="& URLEncode([Route ID#])&[Record ID#] & " & "_fid_61=1"

right ?
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb
No. Syntax errors
Photo of Systems BVI

Systems BVI

  • 530 Points 500 badge 2x thumb
sorry, my bad. Should have been:
URLRoot() & "db/" &  [_DBID_TABLE_1] & "?a=er&dfid=2&rid="& URLEncode([Route ID#])&[Record ID#] & "&_fid_61=1"

I am not sure why there's a dangling &[Record ID#]. You may need to remove that too from your expression.
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 9,286 Points 5k badge 2x thumb
That dangling record ID actually shouldn't be there, that was me using a pre existing button as an example that had Record ID# in there. System is right you would want to remove that and just have the Route ID#
Photo of Chad Brandmire

Chad Brandmire

  • 968 Points 500 badge 2x thumb
Seems to work, but it doesn't edit the field