Can I string an API call to set a field to current user AND then gen add form in a different table?

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • In Progress
I have a formula URL button linked to a different table. I want to string an API call to this so that before it links you over to the new form, it also changes a field (labeld "Marketing Rep") to the current user. Is this doable? Or would I need two buttons?
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
Are you asking to edit the record you are on first then go to the new form?  Or, When you get to the new form change the Marketing Rep?

Either way, they are both possible.

Just need the field ID of the "Marketing Rep" and use the formula "User()" as the value to be written.

If you post your formula, and the field ID, I can help with the syntax
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
The first bit, yea! I need it to edit the record I am on first, then go to the new form on a new table. 

Here is what I have so far, 



URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&AppToken=" &
    "&rid=buawcnbd5pjszvdimycfs3jdpzd" & 
    "&rid=" & [Record ID#] &
    "&_fid_107=" & URLEncode(User()) &

"&rdr="&



URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl())

I am fairly new to QuickBase but I have become knowledgeable enough to be dangerous, but API calls are not my strong suit at all. So this may be a really bad formula
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
Sorry, bothced it in the copy. 

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&AppToken=buawcnbd5pjszvdimycfs3jdpzd" &
    "&rid=" & [Record ID#] &
    "&_fid_107=" & URLEncode(User()) &

"&rdr="&

URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl())
Photo of Matthew Neil

Matthew Neil

  • 31,418 Points 20k badge 2x thumb
You just need to use a "URLEncode()" for the RDR portion.

URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&AppToken=buawcnbd5pjszvdimycfs3jdpzd"&
"&rid="&[Record ID#]&
"&_fid_107="&URLEncode(User())&
"&rdr="&
URLEncode(URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl())

That should do it for you.
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
Yes! Thank you so much, it worked! 
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
If it helps, this formula does change the Marketing Rep to the current user, it just doesnt re direct to the Gen Add Form in the other table.
I took this from the Magic Buttons App.
It might give you the right idea.

URLRoot() & "db/" & [_DBID_CLIENT] & "?a=API_EditRecord&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_28=Completed&_fid_153=Completed&_fid_143=100&rid=" & [Record ID#] & "&rdr=" &    URLEncode(URLRoot() & "db/" & [_DBID_PROJECT_SNAPSHOTS] & "?a=API_AddRecord&apptoken=d9eascudwjxs2sesxkjccwgtq9r&_fid_6=" & [Project Name] & "&_fid_7=" & [Status] & "&_fid_8=" & [Priority] & "&_fid_9=" & [Est Start Date] & "&_fid_10=" & [Est End Date] & "&rdr=" &
        URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]))

// Edit the record and change the status to Completed then redirect to
// Adding a Project Snapshot record to the Project Snapshot table then redirect to
// displaying the original record
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
I'm a bit too new to QuickBase to really try and modify this formula, but I will give it a try. I can kinda see how it would help.

Thank you
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 50,850 Points 50k badge 2x thumb
i have put an application in the exchange called URL Formuals for Dummies.  It explains who to string URLs together.

But here is what should work for your example.  I like to use "formula variables" as it makes the formuals much easier to read.

var text URLONE = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&AppToken=buawcnbd5pjszvdimycfs3jdpzd" &
    "&rid=" & [Record ID#] &
    "&_fid_107=" & URLEncode(User())

var text URLTWO = URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl())

$URLONE
& "&rdr=" & URLEncode($URLTWO)
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
Awesome, I dont really know much about variables, but this is giving me an error saying variable declarations must end in semicolons. I have put a semicolon everywhere I believe a declaration is over, but its giving me the same error, any help?

Thank you so much!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 50,850 Points 50k badge 2x thumb
Right, I'm missing the ending ;

trey this

var text URLONE = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&AppToken=buawcnbd5pjszvdimycfs3jdpzd" &
    "&rid=" & [Record ID#] &
    "&_fid_107=" & URLEncode(User());

var text URLTWO = URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl());

$URLONE
& "&rdr=" & URLEncode($URLTWO)
Photo of Manny De La Cruz

Manny De La Cruz

  • 940 Points 500 badge 2x thumb
var text URLONE = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &    "&AppToken=buawcnbd5pjszvdimycfs3jdpzd" &
    "&rid=" & [Record ID#] &
    "&_fid_107=" & URLEncode(User());

var text URLTWO = URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl()  );

$URLONE
& "&rdr=" & URLEncode($URLTWO)

This is the error I keep getting
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 50,850 Points 50k badge 2x thumb
sorry there is an extra ) at the end of URLTWO


This part should be 


var text URLTWO = URLRoot() & "db/" & [_DBID_APPOINTED_LEADS] & "?a=API_GenAddRecordForm&_fid_21=" & URLEncode ([Agency Name])& "&z=" & Rurl();