Discussions

Expand all | Collapse all

Return to page after Edit Record formula text button.

  • 1.  Return to page after Edit Record formula text button.

    Posted 04-17-2017 14:11
    I use the code:
    "javascript:" &
    "$.get('" & 

    $URLONE &

    "',function(){" &

    "location.reload(true);" &

    "});" 

    & "void(0);"

    to return to the same page a lot in my app and it works incredibly well.  However I only use it on formula URL's and I am wondering what I need to change to make it work on a formula text button instead.  Here is the code:


    var text URLONE = "<a class='Vibrant Success' href=" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]  & "&_fid_56=true" & "> IA Documents Approved </a>";

    "javascript:" &

    "$.get('" & 

    $URLONE &

    "',function(){" &

    "location.reload(true);" &

    "});" 

    & "void(0);"

    Does this code need to be in a formula URL or is there a better way to refresh the page after editing the record?  Thanks in advance.


  • 2.  RE: Return to page after Edit Record formula text button.

    Top
    Contributor
    Posted 04-17-2017 16:01
    The java reload syntax needs to be part of your href in the formula text button.  Or you can make a formula URL field that has all the action, and just reference it in the formula text field.

    "<a class='Vibrant Success' href=' " & [URL Formula Field] & " '> IA Documents Approved </a>"


  • 3.  RE: Return to page after Edit Record formula text button.

    Posted 04-17-2017 16:31
    That's really useful...  Thanks Matthew!


  • 4.  RE: Return to page after Edit Record formula text button.

    Posted 04-17-2017 16:32
    fwiw, i have never been able to get the javascript reload working in conjunction with those href Vibrant buttons, so I'm sitting on the sidelines here to see if it can be done.

    I have it working when a "redirect" (rdr) is used but not for the more useful javascript refresh syntax.  (ie more useful as it works universally regardless of if you are on a record or a report).


  • 5.  RE: Return to page after Edit Record formula text button.

    Top
    Contributor
    Posted 04-17-2017 16:39
    Correction to the syntax, I copied the wrong button.

    If you want the reload to happen within the formula text button you have to nest the quotes.

    With Reload java:
    href=\""&[URL Formula Field]&"\"

    with a RDR:
    href=' " & [URL Formula Field] & " '

    Sorry if that throws you off.


  • 6.  RE: Return to page after Edit Record formula text button.

    Posted 04-17-2017 16:58
    Thx Matthew for posting this and helping the Community


  • 7.  RE: Return to page after Edit Record formula text button.

    Silver
    Contributor
    Posted 04-17-2017 16:46
    Generally, to use color-buttons I use a button for "View" mode (reports and view-form layouts) and a separate one for Edit.  The color choice of the button would be Success (green), Danger (red) and Primary (blue).

    For Edit-Mode

      "<a class='Vibrant Success' title='Start' href='#' style='text-align:center; display:block' onclick=\"" & "javascript:$(function(){window.location.href='" &
      URLRoot() & "db/" & [_DBID_TABLE_ALIAS] & "?act=API_EditRecord&apptoken=xxxxxxxxxx&rid=" & URLEncode([Record ID#])
      & "&_fid_6=" & URLEncode("Text")
      & "&_fid_8=" & URLEncode(User())  
      & "&_fid_7=" & URLEncode(Now())
      & "&rdr=' + escape(window.location); return false;});"
      &"\">Button Label Here</a>"

    For View-Mode/Reports

    "<a class='Vibrant Success' title='Start' style='text-align:center; text-decoration:none' href='javascript:void(window.location.href = \"" & 
      URLRoot() & "db/" & [_DBID_TABLE_ALIAS] & "?act=API_EditRecord&apptoken=xxxxxx&rid=" & URLEncode([Record ID#])
      & "&_fid_6=" & URLEncode("Text")
      & "&_fid_8=" & URLEncode(User())  
      & "&_fid_7=" & URLEncode(Now())
      & "&rdr=' + escape(window.location); return false;});"
      &"\">Button Label Here</a>"

    Hope this is helpful.


  • 8.  RE: Return to page after Edit Record formula text button.

    Posted 04-17-2017 16:53
    Laura, thx for wading in with a most useful answer.


  • 9.  RE: Return to page after Edit Record formula text button.

    Posted 04-17-2017 17:27
    Thank you all for your responses.  These answers will definitely solve some of the issues that I am having right now.  See you all at Empower in a month!