Forum Discussion

MattJones's avatar
MattJones
Qrew Member
3 years ago

Button to check a box, open a URL, and reload while in Edit

This one has been giving me trouble for about a week now. What I am trying to do is create a button that will open a print (I have a field that extracts the URL of a file attachment field), check a box that says the print has been opened, and reload the page while still in edit. The desired workflow would look like this: user adds a child record and before they fill anything out, they have to open a print. When the print has been opened, it will check a box that verifies that they opened the print. Without manually refreshing the page, they should then be able to fill out the child form and save and close. After several failed attempts, here's the current code I'm working with that sort of works:

If([Customer Print URL (Lookup):]="",


URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &

    "&rid=" & [Record ID#] &

    "&_fid_203=1" &

    "&rdr=" &

    URLEncode(URLRoot() & "db/" & Dbid() &

        "?a=dr&rid=" & [Record ID#]),



URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &

    "&rid=" & [Record ID#] &

    "&_fid_203=1" &

     "&rdr=" &

    URLEncode([Customer Print URL (Lookup):]) &

    URLEncode("&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() &

        "?a=dr&rid=" & [Record ID#])))

This will open the print and check the box, but the page does not automatically reload to show the box is checked. It has to be manually refreshed. The work around that I have currently is to only show the button while in view mode. That way they can create the child record, fill out what they need to get the job started, and then save. Then they click the button to open the print, and when they edit to complete the job, the checkbox is checked. The problem with that is that they really should be looking at the print before they start the job. I am pretty sure I would have been able to get it to function before they disabled javascript, but not sure how to do it without. I'm not sure if a code page would be good for this as I haven't messed around too much with those.



------------------------------
Matt Jones
------------------------------

2 Replies

  • PaulPeterson1's avatar
    PaulPeterson1
    Qrew Assistant Captain
    I had a similar question earlier and @Mark Shnier (YQC) had this suggestion:

    "var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&apptoken=tokenmID&rid=" & [Record ID#] & "&_fid_80=1";

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

    $URL
    & "&rdr=" & URLEncode($RefreshPage)"ā€‹

    ------------------------------
    Paul Peterson
    ------------------------------
    • MattJones's avatar
      MattJones
      Qrew Member
      Hi Paul,

      Thanks for the answer, but unfortunately I can't get that to work any better than my current formula. Since I also have to add another variable to open the print. I end up with this:

      var text URL = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
      "&rid=" & [Record ID#] &
      "&_fid_203=1" ;


      var text URLTWO = [Customer Print URL (Lookup):];

      var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

      $URL
      & "&rdr=" & URLEncode($URLTWO)
      & URLEncode("&rdr=" & URLEncode($RefreshPage))

      It will open the print and check the box, but it doesn't refresh the page, which means it has to be manually refreshed to show that the checkbox has been checked. I'm only ever able to get it to perform one redirect. It will either check the box and refresh, but not open the print, or check the box and open the print, but not refresh.

      ------------------------------
      Matt Jones
      ------------------------------