Forum Discussion

AlexFreeman's avatar
AlexFreeman
Qrew Trainee
5 years ago

URL Formula with conditionals

I have a URL - Formula field that I made a button for. It checks a box, records a date and time, and the person who clicked the button (fids 142, 155, and 182 respectively).  I want it to also do the same for a second set of fields (fids 143, 161, 184) if the person clicking the button (fid [User Acceptance User]) matches another field (fid [Request User]).

So, in short I want the workflow like this.
Click Button
Record fields
Then If user matches in two separate fields, record additional fields.

This is the code I'm using now. I'm having a problem with the execution at the bottom. It seems to eat up the url into numbers and letters (I'm assuming because of the If conditional). Is there a way to make this work?

var bool RequestorISTester = If([Request User]=[User Acceptance User],true,false);

var text TestingApproved=
URLRoot() & "db/"
& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
& "&apptoken="&URLEncode([validapptoken])
& "&_fid_142=1"
& "&_fid_155="&URLEncode(Now())
& "&_fid_182="& URLEncode(UserToName(User()));

var text ReDisplay=
URLRoot() & "db/"
& Dbid()
& "?a=dr&rid="
& [Record ID#];

var text MovetoProdApprove=
URLRoot() & "db/"
& Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
& "&apptoken="&URLEncode([validapptoken])
& "&_fid_143=1"
& "&_fid_161="&URLEncode(Now())
& "&_fid_184="& URLEncode(UserToName(User()));

$TestingApproved
& "&rdr=" & If($RequestorISTester=true, URLEncode($MoveToProdApprove), $RequestorISTester=false, URLEncode($ReDisplay))
& URLEncode("&rdr=" & URLEncode($ReDisplay))

------------------------------
Alex Freeman
------------------------------
  • It can be done more simply
    (fid [User Acceptance User]) matches another field (fid [Request User]).

    var text URL =
    URLRoot() & "db/"
    & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
    & "&apptoken="&URLEncode([validapptoken])
    & "&_fid_142=1"
    & "&_fid_155="&URLEncode(Now())
    & "&_fid_182="& URLEncode(UserToName(User()))
    & IF([User Acceptance User] = [Request User],  
        "&_fid_143=1"
         & "&_fid_161="&URLEncode(Now())
         & "&_fid_184="& URLEncode(UserToName(User()));

    var text ReDisplay=
    URLRoot() & "db/"
    & Dbid()
    & "?a=dr&rid="
    & [Record ID#];

    $URL
    & "&rdr=" & URLEncode($ReDisplay)


    I'm not 100% sure I have the count of the (((( and ))) brackets matching in my code.


    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • AlexFreeman's avatar
      AlexFreeman
      Qrew Trainee
      That is fantastic! This worked perfectly, I can't thank you enough. It's nice to have a more clear understanding of the syntax as well. Thank you so much!

      ------------------------------
      Alex Freeman
      ------------------------------