GeorgeKhairalla
3 years agoQrew Cadet
Save a record then revert it
Please bear with me as I try to explain the scenario. I'm looking for a couple things out of this:
1- Is the method I'm trying to implement the best way to do this, or is there a better one
2- I'm trying to correct the behavior of my current method. I'm almost there.
The goal is this:
- our provisioning team would edit a record (with the information that needs to change).
- They push a button (Send for Approval), and check the "Staging" button.
This button has the following code:
//Since [old.field] doesn't work here, we will remember the old values within the formula
var text OLDFIRSTNAME = [First Name];
var text OLDLASTNAME = [Last Name];
var number OLDRELATEDCOMPANYENROLLMENTFORM = [Related Company Enrollment Form];
var textlist OLDPRODUCTERP = [Product ERP];
var textlist OLDPRODUCTADDONAPP = [Product Add-On Apps];
var textlist OLDPRODUCTACCESSORYAPP = [Product Accessory Apps];
var text OLDPLATFORM = [Platform];
var text OLDEMAIL = [Email Address];
var text OLDPHONE = [Office Phone];
//Edit (and Save based on the "SaveBeforeNavigating" class) and switch the "Send Notification" field, to trigger the notification
var text SENDFORAPPROVAL = URLRoot() & "db/" & Dbid() &
"?a=API_EditRecord&rid=" & [Record ID#] &
"&_fid_138=true" &
"&_fid_140=true" &
"&apptoken=xxxxxxxxxxxxxxxx";
//Once the notification is sent, revert back all the values in the record to what they were before the edit, then redirect back to the parent record.
var text REVERT = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] &
"&_fid_6=" & $OLDFIRSTNAME &
"&_fid_7=" & $OLDLASTNAME &
"&_fid_61=" & $OLDRELATEDCOMPANYENROLLMENTFORM &
"&_fid_70=" & $OLDPRODUCTERP &
"&_fid_71=" & $OLDPRODUCTADDONAPP &
"&_fid_72=" & $OLDPRODUCTACCESSORYAPP &
"&_fid_73=" & $OLDPLATFORM &
"&_fid_9=" & $OLDEMAIL &
"&_fid_10=" & $OLDPHONE &
"&_fid_136=false" &
"&rdr=" & URLEncode(URLRoot() & "db/" & [_DBID_COMPANY_ENROLLMENT] & "?a=dr&rid=" & [Related Company Enrollment Form]);
//Put it all together
"<a class='Vibrant Success SaveBeforeNavigating' href='" & $SENDFORAPPROVAL & "&NextURL=" & URLEncode($REVERT) & "'>Send for Approval - Edit</a>"
I want this to Save the record. Which should create a "Notification" based on _fid_138 (Send Notification - Checkbox), which is now checked.
The next step would now use the "OLD" variables in the formula, to "reset" those fields back to their original values.
The end user now received a notification with a URL Formula for Approving that request, will require them to sign in, and write the record under their own credential, resulting in a fully audited entry.
The problem I'm having with the current setup, having "SaveBeforeNavigating", the changes don't get reverted, and I get an XML return stating that there were no errors, when i hit back on the browser, it doesn't revert the changes.
Looking at the resulting URL, I see that the "OLD" values are actually the "NEW" values. So, I guess they weren't retained through the save.
Any ideas what I could change to get this workflow to work? (If possible).
Could triggering a pipeline after the save work? and if so, is it possible to grab the previous values of the fields within the pipeline?
Alternatively, if I'm over complicating this in my head, if anyone might have any better way to accomplish this, I welcome the suggestions.
Thanks!
------------------------------
George Khairallah
CTO
gotomyerp, LLC
------------------------------
1- Is the method I'm trying to implement the best way to do this, or is there a better one
2- I'm trying to correct the behavior of my current method. I'm almost there.
The goal is this:
- our provisioning team would edit a record (with the information that needs to change).
- They push a button (Send for Approval), and check the "Staging" button.
This button has the following code:
//Since [old.field] doesn't work here, we will remember the old values within the formula
var text OLDFIRSTNAME = [First Name];
var text OLDLASTNAME = [Last Name];
var number OLDRELATEDCOMPANYENROLLMENTFORM = [Related Company Enrollment Form];
var textlist OLDPRODUCTERP = [Product ERP];
var textlist OLDPRODUCTADDONAPP = [Product Add-On Apps];
var textlist OLDPRODUCTACCESSORYAPP = [Product Accessory Apps];
var text OLDPLATFORM = [Platform];
var text OLDEMAIL = [Email Address];
var text OLDPHONE = [Office Phone];
//Edit (and Save based on the "SaveBeforeNavigating" class) and switch the "Send Notification" field, to trigger the notification
var text SENDFORAPPROVAL = URLRoot() & "db/" & Dbid() &
"?a=API_EditRecord&rid=" & [Record ID#] &
"&_fid_138=true" &
"&_fid_140=true" &
"&apptoken=xxxxxxxxxxxxxxxx";
//Once the notification is sent, revert back all the values in the record to what they were before the edit, then redirect back to the parent record.
var text REVERT = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] &
"&_fid_6=" & $OLDFIRSTNAME &
"&_fid_7=" & $OLDLASTNAME &
"&_fid_61=" & $OLDRELATEDCOMPANYENROLLMENTFORM &
"&_fid_70=" & $OLDPRODUCTERP &
"&_fid_71=" & $OLDPRODUCTADDONAPP &
"&_fid_72=" & $OLDPRODUCTACCESSORYAPP &
"&_fid_73=" & $OLDPLATFORM &
"&_fid_9=" & $OLDEMAIL &
"&_fid_10=" & $OLDPHONE &
"&_fid_136=false" &
"&rdr=" & URLEncode(URLRoot() & "db/" & [_DBID_COMPANY_ENROLLMENT] & "?a=dr&rid=" & [Related Company Enrollment Form]);
//Put it all together
"<a class='Vibrant Success SaveBeforeNavigating' href='" & $SENDFORAPPROVAL & "&NextURL=" & URLEncode($REVERT) & "'>Send for Approval - Edit</a>"
I want this to Save the record. Which should create a "Notification" based on _fid_138 (Send Notification - Checkbox), which is now checked.
The next step would now use the "OLD" variables in the formula, to "reset" those fields back to their original values.
The end user now received a notification with a URL Formula for Approving that request, will require them to sign in, and write the record under their own credential, resulting in a fully audited entry.
The problem I'm having with the current setup, having "SaveBeforeNavigating", the changes don't get reverted, and I get an XML return stating that there were no errors, when i hit back on the browser, it doesn't revert the changes.
Looking at the resulting URL, I see that the "OLD" values are actually the "NEW" values. So, I guess they weren't retained through the save.
Any ideas what I could change to get this workflow to work? (If possible).
Could triggering a pipeline after the save work? and if so, is it possible to grab the previous values of the fields within the pipeline?
Alternatively, if I'm over complicating this in my head, if anyone might have any better way to accomplish this, I welcome the suggestions.
Thanks!
------------------------------
George Khairallah
CTO
gotomyerp, LLC
------------------------------