Forum Discussion

Kelly-AnnTainto's avatar
Kelly-AnnTainto
Qrew Trainee
20 days ago

Nesting API Button Help (Add record and update another)

I have 4 tables I'm working with: 

License Master (parent table)

Pending Locations (parent table

Suggested Licenses (a child (many to many table) to both above)

Licenses (child (many to many table) to both License Master and Pending Locations / unrelated to Suggested Licenses)

I have a pipeline that searches criteria in the License Master to see if it matches criteria in the Pending Location.  If any License Master records match they are copied to the Suggested Licenses table.   

On the Licenses main form the Suggested License embedded report has the API button I'm trying to create.    I want to be able to click the button to Add the Suggested License record to the Licenses table if it is applicable for that location.  Then edit the Suggested License record by checking the box "Added to Location" to then filter it off of the Suggested License report for that location.     

This is the formula I currently have and I'm so close.  It adds the record and refreshes back to the Licenses page, but it does not perform the 2nd API to check off the box in the Suggested License record.   

var text ADD=URLRoot() & "db/" & " [_DBID_PERMITS_LICENSES]"
& "?act=API_AddRecord"
& "&_fid_95=" & URLEncode([Related Pending Location])
& "&_fid_44=" & URLEncode([Related License Master])
& "&_fid_8=" & URLEncode([License Master - Related Issuing Authority])
& "&_fid_21=" & URLEncode([License Master - Related Remittance Agent])
& "&apptoken=XXXXXX";

var text UpdateSuggestedLicense=URLRoot() & "db/" & [_DBID_SUGGESTED_LICENSES]  
& "?act=API_EditRecord"
& "rid=" & URLEncode([Record ID#])
& "&_fid_17=true" 
& "&apptoken=XXXXXXX";

$ADD
& "&rdr=" & URLEncode($UpdateSuggestedLicense)
& URLEncode("&rdr=" & URLEncode($RefreshPage))

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

Any help to what I'm missing would be awesome!  Thank you.