Forum Discussion

BaileyDesormeau's avatar
BaileyDesormeau
Qrew Member
6 months ago

Creating a Formula Rich Text Field

Good afternoon,

I am trying to create a button that will save a record then put me back into edit mode then copy information from one field into another. I have done research on this and found two separate solutions. I have the rich text formula for the save and conintue button below:

var text RID = If([Mission ID#]>0, ToText([Mission ID#]), "%%rid%%");
 
var text URL = URLRoot() & "db/" & Dbid() & "?a=er"
& "&rid="& $RID;
 
"<a class='SaveBeforeNavigating' data-replaceRid=true style=\"text-decoration:none; background: #117a39; border-radius: 5px; color: #FFFFFF; display: inline-block; padding: 4px 4px 4px 4px; width:140px; text-align: center; text-shadow: none; border: 2px solid #0863f5; font-size: 12px \"href='"
& $URL
& "'>Save and Continue</a>"

Then on my own I created the formula url button below:

var text LINKMISSION = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Mission ID#] & "&_fid_153=" & [Mission ID#] &"&apptoken=bvtrs6mvpga7tb9z7ud6b99nvrn";
var text TOTABLES = URLRoot() & "db/" & Dbid() & "?a=er&rid=" & [Mission ID#];
$LINKMISSION
& "&rdr=" & URLEncode($TOTABLES)

Now I need to add them together! This is where I do not have the knowledge to do so.

Thanks in advance for your help!



------------------------------
Bailey Desormeaux
------------------------------

10 Replies

  • Something like this should do the trick. I got it to work with a few tests so you may need to tweak a bit for your use case. I copied my own example below

    _________________________
    var text view = URLRoot() & "db/" & Dbid() & "?a=er&rid=";
    var text url = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & If( [Record ID#] > 0, ToText([Record ID#]),"%%rid%%") & "&_fid_38=101&rdr=" & URLEncode($view) & If( [Record ID#] > 0, ToText([Record ID#]),"%%rid%%");
     
    var text link = "<a href='" & $url & "' data-replaceRid='true' style='font-size: 11pt;margin-left: 5px; margin-top: 0px; height: 33px; width: 160px; text-align:center;background-color:#13294d;color:white;background-image: linear-gradient(to bottom, #13294d 0%, #13294d 100%);' class='SaveBeforeNavigating Vibrant'>Save and Continue</a>";
     
    $link
    _________________________
    The idea is that you do the 'EditRecord' first in the formula since the SaveBeforeNavigating will commit the record into the system, and then the %%rid%% syntax along with the data-ReplaceRID will swap out the new RID for both instances so that your editRecord and redirect both work as intended. In your EditRecord call where you're doing a redirect - just make sure that you leave the RID piece outside of the URLEncode - otherwise the %% will get encoded and the data-replaceRID won't operate as intended. 


    ------------------------------
    Chayce Duncan
    ------------------------------
    • BaileyDesormeau's avatar
      BaileyDesormeau
      Qrew Member

      The only issue is QB is saying i am missing an app token. I am unsure of where and how to put the app token in this formula. Also, is there somewhere I can learn more in depth about these URL and Rich Text formulas? I am only learning form the discussions area of the QB community and it would really help if I could learn this more in depth. Thanks for your help!



      ------------------------------
      Bailey Desormeaux
      ------------------------------
      • ChayceDuncan's avatar
        ChayceDuncan
        Qrew Captain

        My test system doesn't require tokens so I took it out. In your editRecord call - just add this back: 

        (the actual token needs to be updated with your token)

        API_EditRecord&apptoken=xxxxxx&rest of your code

        As for your question, QB university will be the primary place for info - items like the %%rid%% unfortunately aren't really documented consistently. They live in the archives of the forum or miscellaneous articles that I've found over the years. 



        ------------------------------
        Chayce Duncan
        ------------------------------