Discussions

 View Only
  • 1.  Create URL formula that redirect and also calls a script

    Posted 11-14-2017 19:06
    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!


  • 2.  RE: Create URL formula that redirect and also calls a script

    Posted 11-14-2017 20:14
    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='#'
    onclick=\"javascript:
    $.getScript('" & URLRoot() & "db/" &Dbid() & "?a=dbpage&pagename=SCRIPT.JS&rand='+Math.random());
    $.get('" & $linkbase & "',function(){" & "location.reload(true);" & "});"
    & "void(0);\">
    </a>"

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


  • 3.  RE: Create URL formula that redirect and also calls a script

    Posted 11-17-2017 09:59
    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.

    Thanks,

    Gaurav