Forum Discussion

ChristianRexach's avatar
ChristianRexach
Qrew Trainee
6 years ago

Have 2 API Formulas in one URL Button

I want to have a workflow where a Field Engineer makes a Request for a part and then if it's approved have Dispatch click a button which will create a new record on another table and also edit a checkbox on the original record letting us know it's been approved. I can get the 2 formulas to work individually but not together. Here are the 2 formulas I want to work on a single button:

Create new record on another table with data from this record:
URLRoot() & "db/" & [_DBID_PARTS] & "?act=API_GenAddRecordForm"& "&_fid_19=" & URLEncode([CSE - Full Name])
& "&_fid_20=" & URLEncode([Part Name/Desc. (s)]& "\n\n" &[Tool Name/Desc.])
& "&_fid_6=" & URLEncode([Part Number(s)]& "\n\n" &[Tool Number] )
& "&_fid_32=" & URLEncode([Equipment Name / Desc.])
& "&_fid_21=" & URLEncode([FL Number / Equipment Number])

Check the Checkbox:
URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#] & If([Sent To Purchasing]=true, "&_fid_14=0", "&_fid_14=1")
& "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])
  • If the dispatcher doesn't need to add any other information to the form in the process of creating the record, you may have better luck with API_AddRecord instead of GenAddRecordForm. They work similarly, but AddRecord will just add a record to the table without going through the process of using the form.

    Additionally, I don't believe that GenAddRecordForm can use "rdr" to do a subsequent API call, but AddRecord can. Here's a little more info about that: https://community.quickbase.com/quickbase/topics/using-z-rurl-and-rdr-in-formula-url-fields

    If you do need to add more information to the form while it's being created, you could try to put the checkbox API call first, and have it rdr to the GenAddRecordForm call. Not 100% sure if that would work, but may be something to try.
  • They have to add more information to the record so I definitely need the GenAddRecordForm. I'm not an expert at all when it comes to API calls and I've never used "rdr" and the link you provided isn't helping me much. Could you help me with what the syntax should look like?
  • I'm no pro with APIs either, but since you need to add info to the record that is generated, you could try to do the checkbox part first, followed by the GenAddRecord part, something like this:


    URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#] & If([Sent To Purchasing]=true, "&_fid_14=0", "&_fid_14=1")
    & "&rdr=" 

    &URLEncode(URLRoot() & "db/" & [_DBID_PARTS] & "?act=API_GenAddRecordForm"& "&_fid_19=" & URLEncode([CSE - Full Name])
    & "&_fid_20=" & URLEncode([Part Name/Desc. (s)]& "\n\n" &[Tool Name/Desc.])
    & "&_fid_6=" & URLEncode([Part Number(s)]& "\n\n" &[Tool Number] )
    & "&_fid_32=" & URLEncode([Equipment Name / Desc.])
    & "&_fid_21=" & URLEncode([FL Number / Equipment Number])
    &"&z=" & Rurl())

    The last line I *think* should return you to the page you started on.

    Again, I'm no expert, and with APIs I typically have to play around a bit with them, but that could be the general idea.

    Alternatively, could an automation fired off of the creation of a record on your Parts table that would go and then check the box be an option if the double-API call in a URL doesn't work?

    Hopefully that's helpful!
  • It works! Thanks!! Only thing I changed was eliminating the last line since I want them to be forwarded to the new record to finish inputting the information and save it.