Forum Discussion

ChadBrandmire's avatar
ChadBrandmire
Qrew Assistant Captain
8 years ago

Button to edit a field and save record

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>"
  • 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. 
  • ChadBrandmire's avatar
    ChadBrandmire
    Qrew Assistant Captain
    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
  • SystemsBVI's avatar
    SystemsBVI
    Qrew Assistant Captain
    Should be :
    URLRoot() & "db/" &  [_DBID_TABLE_1] & "?a=er&dfid=2&rid="& URLEncode([Route ID#])&[Record ID#] & " & "_fid_61=1"

    right ?
  • SystemsBVI's avatar
    SystemsBVI
    Qrew Assistant Captain
    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.
  • 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#