Create URL formula that redirect and also calls a script

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • In Progress
I need to create a button that will update a record and redirect back to the edit form, and at the same time, trigger a script to run in the background. 
The orginal URL formula field states the following:
URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&AppToken=XXXXX&rid=" & URLEncode ([Record ID#])& "&_fid_233=yes&_fid_254=" & Now() & "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])
Now, to add a call to a script page, I am at a loss. In most cases, I would do a separate button to call it, but it should only be called once on the page, and triggered when the button above is clicked. It makes sense then to add it to the same formula URL field. My initial thought was to just add it to the URL, but is not currently working. So I am not sure what to do next. Below is the text I need to add. 
$.getScript('" & URLRoot() & "db/" &Dbid() & "?a=dbpage&pagename=PAGENAME.JS&rand='+Math.random())\"
The worst part is, I had this working a few weeks ago, and I cannot find my documentation for how I ended up getting it to work. 
Any ideas would be appreciated, thanks!
Photo of Ursula Ll

Ursula Ll

  • 1,682 Points 1k badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Ursula Ll

Ursula Ll

  • 1,682 Points 1k badge 2x thumb
Ended up doing some funky stuff to get it working right. I am posting it here just in case anyone else comes across this issue. 

var Text encoded = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];
var Text linkBase = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&AppToken=XXXX&rid=" & URLEncode ([Record ID#])& "&_fid_233=yes&_fid_254=" & Now() & "&rdr=" & $encoded;

"<a class='Vibrant' href='#'
$.getScript('" & URLRoot() & "db/" &Dbid() & "?a=dbpage&pagename=SCRIPT.JS&rand='+Math.random());
$.get('" & $linkbase & "',function(){" & "location.reload(true);" & "});"
& "void(0);\">

Whew, this one took a lot of brain use, glad I got it working
Hi Ana,

I have a scenario where I need to first refresh the record then, edit the same record and update the parent record. Can you please help me with that?

If you want, you can take a look at my question here.

Do let me know if you need any further information.