URL button to populate a field

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered

Can someone look at my formula and tell me why field 138 not populating the word Request when I click the URL button


URLRoot() & "db/" & Dbid() &"?a=er&dfid=12&rid=" & URLEncode ([Record ID#])&"&_fid_138=" &URLEncode ("Request") &"&z=" & Rurl()

Photo of Shontay

Shontay

  • 490 Points 250 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,904 Points 20k badge 2x thumb
Several Typos and unnecessary URL Encodings. Formatting the formula makes it easier to debug. Try this:

URLRoot() &
"db/" &
DBID() &
"?a=er" &
"&dfid=12" &
"&rid=" & [Record ID#] &
"&_fid_138=Request" &
"&z=" & Rurl()
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,448 Points 50k badge 2x thumb
Actually, I don't believe that the ?a=er operation can populate a field.  It is not a real API call.  

What is it that you are trying to do.  Are you trying to open the record you are on in edit mode and populated a field, leaving the user sitting in edit mode?
Photo of Shontay

Shontay

  • 490 Points 250 badge 2x thumb
I am trying to open a related record and populate field 138 with the word request through the URL button
Photo of Shontay

Shontay

  • 490 Points 250 badge 2x thumb
It still didn't populate field 138 with Request
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 29,904 Points 20k badge 2x thumb
I think Mark is correct here - adding &_fid_138 to the ?a=er URL does nothing. I think you are trying to use  or confusing the behavior of ?a=API_EditRecord or ?a=API_GenAddRecordForm which can take field parameters.

In any event the solution is to use pure JavaScript - formulas will just mess you up.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,448 Points 50k badge 2x thumb
The a=er won't populate anything. I think it can't be done natively.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,448 Points 50k badge 2x thumb
Actually, there is a way.

var text URLONE = URLRoot & "db/" & dbid() & "?act=API_EditRecord&rid=" totext([Record ID#]) & "&_fid_138=Request";

var text URLTWO =  and insert your code her for "a=er"

$URLONE
& "&nexturl="  & URLEncode($URLTWO)
Photo of Shontay

Shontay

  • 490 Points 250 badge 2x thumb
Now I am getting two error messages
var text URLONE =URLRoot & "db/" & dbid() & "?act=API_EditRecord&rid=" totext([Record ID#]) & "&_fid_9=" &URLEncode([DSAC_SLOT_DATE]);

var text URLTWO =  a=er&dfid=12&rid="

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

First message The argument list of functions URLRoot must begin with a left perenthesis
Second message the variable declaration must end with a semi-colon
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,448 Points 50k badge 2x thumb
Shontay,

The code I posted was not meant to be complete code, but was intended to give you direction.  If you want to get into the world of using APIs in URL formulas, one source of training is an app I have posted to the Exchange called URL Formuals for dummies.

The actual suggested code would be this



var text URLONE = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#]) & "&_fid_138=Request";

URLRoot() & "db/" & Dbid() &"?a=er&dfid=12&rid=" & URLEncode ([Record ID#])
& "&z=" & Rurl();


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


The first statement should edit the record to put Request into field ID 138.  The second part will then display the record in edit mode.
Photo of Michael Frishman

Michael Frishman

  • 294 Points 250 badge 2x thumb
Going to bump an old thread for anything looking at this in the future for help.

If I understand the logic of this, in the code above, aren't you missing the var statement to assign URLTWO in front of the URLRoot on the 3rd line?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,448 Points 50k badge 2x thumb
Yes you are correct. It should be

Shontay,

The code I posted was not meant to be complete code, but was intended to give you direction. If you want to get into the world of using APIs in URL formulas, one source of training is an app I have posted to the Exchange called URL Formuals for dummies.

The actual suggested code would be this

var text URLONE = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#]) & "&_fid_138=Request";

var text URLTWO = URLRoot() & "db/" & Dbid() &"?a=er&dfid=12&rid=" & URLEncode ([Record ID#])
& "&z=" & Rurl();

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

The first statement should edit the record to put Request into field ID 138. The second part will then display the record in edit mode.