Forum Discussion

GeorgeKhairalla's avatar
GeorgeKhairalla
Qrew Trainee
3 years ago

Attempting to create a record via email approval button with API_GenAddRecord

Hi, I'm trying to create a button that gets sent to the end user in an email message.

My Use Case:
Our internal support team would fill a form on behalf of the user with the necessary information, and the URL would get populated while the agent is filling the form. Once done, the agent would send that URL via some notification workflow (which I haven't quite thought through fully yet), containing an "Approve" or "Deny" button to the end user.

If the user Approves, then they will be redirected to Sign-In (if not already signed in), and the record would get created, with them being the owner, thereby creating a proper audit record of their approval.

All is working except populating some multi-select fields.  Below is a truncated snippet of how I'm breaking down the values of the multi-select fields and inserting them into the URL formula.

Some things I have tried:
- I tried using the API_GenRecordAddForm , which actually works well with the multi-select fields, however, that API call can't automatically save the record, which is a requirement for this scenario.
- I have looked into API_FieldAddChoices, but that is an action on its own, and I'm not sure if would be compatible while I'm trying to create a new record? maybe save and send to a "&NextURL" to an ?a=API_FieldAddChoices?
   - My other challenge with using this one -- if I were to do so --  is how to create a formula that breaks down the values, as this API_FieldAddChoices requires a "Choice=X&Choice=Y&Choice=Z" formatting, etc...

Any guidance appreciated!

// ---------- Product Bullets --------------
//ERP PRODUCTS - MULTI-SELECT FIELDS
var text ERPPRODUCTS = ToText([Product ERP]);
var text ERPPARTONE = Trim(Part($ERPPRODUCTS,1,";"));
...etc...
var text ERPPARTTWENTY = Trim(Part($ERPPRODUCTS,20,";"));

var text URLERP = $ERPPARTONE & ";" ...etc... ";" & $ERPPARTTWENTY;

// Add-On Products
var text ADDONPRODUCTS = ToText([Product Add-On Apps]);
var text ADDONPARTONE = Trim(Part($ADDONPRODUCTS,1,";"));
...etc...
var text ADDONPARTTWENTY = Trim(Part($ADDONPRODUCTS,20,";"));

var text URLADDON = $ADDONPARTONE & ";" ...etc... ";" & $ADDONPARTTWENTY;

// Accessory Products
var text ACCESSORYPRODUCTS = ToText([Product Accessory Apps]);
var text ACCESSORYPARTONE = Trim(Part($ACCESSORYPRODUCTS,1,";"));
...etc...
var text ACCESSORYPARTTWENTY = Trim(Part($ACCESSORYPRODUCTS,20,";"));

var text URLACCESSORY = $ACCESSORYPARTONE & ";" & ...etc... ";" & $ACCESSORYPARTTWENTY;


// ------------ End Product Bullets -------------------

var text SIGNIN = URLRoot() & "db/main?a=SignIn";

var text APPROVED = URLRoot() & "db/" & Dbid() & 
"?a=API_GenAddRecordForm" & 
"&_fid_6=" & [First Name] & 
"&_fid_7=" & [Last Name] & 
"&_fid_61=" & [Related Company Enrollment Form] & 
"&_fid_70=" & $URLERP & 
"&_fid_71=" & $URLADDON & 
"&_fid_72=" & $URLACCESSORY & 
"&_fid_73=" & [Platform] & 
"&_fid_9=" & URLEncode([Email Address]) & 
"&_fid_10=" & URLEncode([Office Phone]) & 
"&apptoken=xxxxx" & 
"&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dbpage&pageID=10)";

"<a class='Vibrant Success' href='" & $SIGNIN & "&NextURL=" & URLEncode($APPROVED) & "'>APPROVED</a>"



------------------------------
George Khairallah
CTO
gotomyerp, LLC
------------------------------

1 Reply

  • I was about to delete the post, but thought I'd keep it in case anyone else may be looking for a similar solution.
    Turns out that I was over-complicating the breakdown of the multi-select fields. (used that break down method to design bulleted <li> points under a different scenario.

    The solution here is simply to refer to the actual multi-select field itself in the API_AddRecord call, and it works like a charm.

    So the working code for this would be something like this:
    var text SIGNIN = URLRoot() & "db/main?a=SignIn";
    
    var text APPROVED = URLRoot() & "db/" & Dbid() & 
    "?a=API_AddRecord&_fid_6=" & [First Name] & 
    "&_fid_7=" & [Last Name] & 
    "&_fid_61=" & [Related Company Enrollment Form]& 
    "&_fid_70=" & [Product ERP] & // Multi-select field
    "&_fid_71=" & [Product Add-On Apps] & // Multi-select field
    "&_fid_72=" & [Product Accessory Apps] & // Multi-select field
    "&_fid_73=" & [Platform] & 
    "&_fid_9=" & [Email Address] & 
    "&_fid_10=" & [Office Phone] & 
    "&apptoken=xxxxxx" & 
    "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dbpage&pageID=10)";
    
    "<a class='Vibrant Success' href='" & $SIGNIN & "&NextURL=" & URLEncode($APPROVED) & "'>APPROVED</a>"​

    Cheers!

    ------------------------------
    George Khairallah
    CTO
    gotomyerp, LLC
    ------------------------------