Discussions

Expand all | Collapse all

Button to edit a field and save record

  • 1.  Button to edit a field and save record

    Posted 12-26-2017 21:48
    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>"


  • 2.  RE: Button to edit a field and save record

    Posted 12-27-2017 19:15
    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. 


  • 3.  RE: Button to edit a field and save record

    Posted 12-27-2017 19:56
    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


  • 4.  RE: Button to edit a field and save record

    Posted 12-27-2017 20:00
    Should be :
    URLRoot() & "db/" &  [_DBID_TABLE_1] & "?a=er&dfid=2&rid="& URLEncode([Route ID#])&[Record ID#] & " & "_fid_61=1"

    right ?


  • 5.  RE: Button to edit a field and save record

    Posted 12-27-2017 20:37
    No. Syntax errors


  • 6.  RE: Button to edit a field and save record

    Posted 12-27-2017 20:56
    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.


  • 7.  RE: Button to edit a field and save record

    Posted 12-27-2017 20:58
    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#


  • 8.  RE: Button to edit a field and save record

    Posted 12-27-2017 21:07
    Seems to work, but it doesn't edit the field