Forum Discussion

RobinKautz's avatar
RobinKautz
Qrew Trainee
9 years ago

How do I get two URL's to work with a single button click

I have two URL's that I am trying to get to work within a URL formula button AND with one click of that button AND to redirect back to the original record, but I am having trouble.   The button is located within the records of the Opportunities Table.  
URLONE activates a code page which checks a box for every record in a child table of Opportunities called Activities that is not already checked.  Once complete, the code page currently redirects to a report in the Activities Table, but I can alter that if I need to.
URLTWO takes me to the Project Table form which has a reverse relationship with Opportunities and auto fills in a few of the fields.  I then fill in a few other fields and hit save.  After the project record is saved it redirects back to that same record in the Opportunities Table.  

I can get it to perform one URL or the other, but not both, and certainly not both with a single button click.  Nor can I get it to do both and redirect back to the original Opportunity record. Here is the URL:  (This button is located within the Opportunity Table)



var text URLONE = URLRoot() & "db/" & Dbid() & "?a=dbpage&pageid=94";

var text URLTWO = URLRoot() & "db/" & [_DBID_PROJECTS] & "?a=API_GenAddRecordForm&_fid_270=" & URLEncode ([Record ID#])&
"&_fid_75=" & URLEncode ([Related Company]) &
"&_fid_242=" & URLEncode ([Opportunity Name]) &
"&z=" & Rurl();

If(([Stage]="Won" or [Has Billable Work Started Yet?]="Yes") and [# of Projects]=0,
$URLONE
& "&rdr=" & URLEncode($URLTWO),
"")
  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    You'll need to add another rdr at the end.  Something like;

    &rdr="&URLEncode(URLRoot()&"db/bk9kers7d?a=dr&rid="& [Record ID#])
  • The problem I'm still having is that it doesn't perform both URL's.  It only does URLTWO.  
  • Yes, a fairly simple code page.  I'm not an expert in this area.   I just copied a different code page I had and made a few tweaks to do what I wanted.  No matter what I try I still can't get both URL's to work sequentially.  
  • Sorry, I can't help you with code pages.  Unless perhaps  you try replacing &rdr=  with &nexturl=

    but that is probably a 1 in 100 shot.
  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    I should have looked at the details more.  My bad.

    You cannot run a code page, AND THEN some other API_ call via One button call

     You need to either run the API call first and then the code page OR have the API run at the end of the code page.  i.e. your API_AddGenRecordFrom needs to be included in your code page.

    If you had an API_Edit then a code page call, that works, but because you are looking to go to the add form, you will need all of that to be included in the code page itself.  With variable passing, which gets tricky if you are not a coder.


    Or break it into two different button clicks if modifying the code page is not your strength.
    (which is my recommendation)
    One button does the code page, the next button does the new record.