Forum Discussion

MichelleCraig's avatar
MichelleCraig
Qrew Member
2 years ago

change multiple fields with one button

so I need to make my cancel button change one field to "Cancelled" (which it is doing) but now I need to get another field (fid 65) to change to "Closed" and I have tried to simply add on the field ID 65 but that hasn't worked out so well as I get an error.

here is my full code w/o my app ID tho

var text RID = If([Record ID#] > 0, ToText([Record ID#]), "%%rid%%"); 

var text Edit =  URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & $RID & "&apptoken=missed one &_fid_79=" & URLEncode("Cancelled") &

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & $RID & "&apptoken=missed one &_fid_65=" & URLEncode("Closed");

var text DisplayURLMissingRID = URLRoot() & "db/" & Dbid() & "?a=dr&rid="; 


var text URL = $Edit

& "&rdr=" & URLEncode($DisplayURLMissingRID) & $RID;

"<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #000000; border-radius: 10px; color: #ffffff; display: inline-block; padding: 5px 5px 5px 5px; width:200px; text-align: center; text-shadow: none; border: 2px solid #000000; font-size: 12px \"href='"
& $URL
& "'>Cancel</a>"

this is the error that I get:

<qdbapi>
<action>API_EditRecord</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<rid>220</rid>
<num_fields_changed>0</num_fields_changed>
<update_id>1680093311158</update_id>
</qdbapi>

so while I would guess that this change is wrong (obviously), but the ask is possible, just went down the wrong road. 

thank you for your help!



------------------------------
Michelle Craig
------------------------------

  • It actually is saying you aren't getting an error (thats why it says No error in the middle). This means it is not getting to your redirect and doesnt know where to go. However, your syntax to change multiple fields is simpler than you are making it. You do not need to call the edit record api multiple times. Rather:

    var text Edit =  
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & $RID
    & "&apptoken=myapptokenhere
    & "&_fid_79=" & URLEncode("Cancelled")
    & "&_fid_65=" & URLEncode("Closed");

    A couple things to note.

    1. Good practice not to post your app token as it is an extra security level and best to keep that confidential.
    2. You can keep adding as many fields as you like to set.
    3. The URL Encoding is never a bad idea and won't hurt anything, but really is designed to be sure to take care of special characters (so when in doubt, use it), but in your case if you wanted, you could simplify to:

    var text Edit =  
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & $RID
    & "&apptoken=myapptokenhere
    & "&_fid_79=Cancelled" 
    & "&_fid_65=Closed";



    ------------------------------
    Mike Tamoush
    ------------------------------
    • MichelleCraig's avatar
      MichelleCraig
      Qrew Member

      dang it...edited...i thought id done that, what happens when you multitask...thank you



      ------------------------------
      Michelle Craig
      ------------------------------

    • MichelleCraig's avatar
      MichelleCraig
      Qrew Member

      it worked, thank you, coding is hard, but I am learning - also any chance you can edit the "original message" in your response to delete that token? - cant believe I did that.



      ------------------------------
      Michelle Craig
      ------------------------------