Forum Discussion

AleishaAldrich2's avatar
AleishaAldrich2
Qrew Member
2 years ago
Solved

URL Formula Button w/ Two API Calls

I am working with 3 tables: Parent Table: Work Orders--> Intermediary (Child) Table: Subcontractor Quotes--> Child Table: Status History. I have an embedded report on my Work Order form w...
  • MarkShnier__You's avatar
    2 years ago
    You were really close The problem with the missing rid was that you had a leading _ underscore that did not belong.  Here is how I would write it to be all in one button.  I also strongly recommend that you make your formula as tidy and readable as possible like I have below.


    var bool ShowButton = Contains([Quote Status], "Approved by PM");

    var text Dispatch =
    URLRoot() & "db/" & [_DBID_STATUS_HISTORY]
    & "?a=API_AddRecord"
    & "&_fid_16=" & URLEncode ([Record ID#])
    & "&_fid_10=Subcontractor Dispatched"
    & "&_fid_11=Subcontractor Quote Status"
    & "&_fid_9=" & URLEncode(User())
    & "&apptoken=xxxxxxxxxxxxx";

    var text UpdateWorkOrder=
    URLRoot() & "db/" & [_DBID_WORK_ORDERS]
    & "?a=API_EditRecord"
    & "&rid=" & URLEncode([Related Work Order])
    & "&_fid_155=true"
    & "&apptoken=xxxxxxxxxxx";

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

    // the this is the syntax to nest three successive API calls, but I set that also to be a formula variable.

    var text DoIt=
    $Dispatch
    & "&rdr=" & URLEncode($UpdateWorkOrder)
    & URLEncode("&rdr=" & URLEncode($RefreshPage));

    IF($ShowButton, $DoIt)


    Feel free to post back if there are any syntax errors, but include a copy of the code.




    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------