Custom Docusign Button in Skuid using Snippet - CSRF Issue
I have a custom JS button in SF Classic that is used to send documents to Docusign, and I've successfully replicated the button in a Skuid snippet:
The URL merges all the values correctly, however, due to the Docusign Visualforce pages enforcing CSRF...I get this errror on the resulting page:
Appreciate the assist!
var params = arguments[0],
$ = skuid.$; var model = skuid.model.getModel('UltrasoundRecord'); var ClientUltrasound = skuid.model.getModel('UltrasoundRecord').getFirstRow(); //Docusign Options Setup var CRL='Email~'+ ClientUltrasound.Medical_Director_Email__c +';Role~Medical Director;AccessCode~'+ClientUltrasound.Clinic_Ultrasound_Password__c+';FirstName~'+ClientUltrasound.Medical_Director_First_Name__c+';LastName~'+ClientUltrasound.Medical_Director_Last_Name__c; var DST='*******************************'; //Omitted var CEM= ClientUltrasound.Ultrasound_Note_to_MD__c; var CES=ClientUltrasound.Ultrasound_Email_Subject__c; var url = '/apex/dsfs__DocuSign_CreateEnvelope?[SourceID=' + ClientUltrasound.Id + ']&CRL='+CRL+'&DST='+DST+'&CEM='+CEM+'&CES='+CES; console.log('Merged URL: ' + url); window.open(url.text());
The URL merges all the values correctly, however, due to the Docusign Visualforce pages enforcing CSRF...I get this errror on the resulting page:
The link you followed isn’t valid. This page requires a CSRF confirmation token. Report this error to your Salesforce administrator.I know how to fix this using { !URLFOR() } in Visualforce/Apex, but I'm at a loss for how to implement it in Skuid/JS. How can I get the correct URL for a CSRF protected Visualforce page in a Skuid snippet?
Appreciate the assist!
Tagged:
2
Categories
- 7.9K Questions
- 926 Ideas
- 220 Discussion Categories
- 178 General
- 9 Community Feedback
- 3 Community Info
- 18 Knowledge Base
Comments
A few things you might try:
1. Define a function in your Visualforce code via a <script/> tag that uses the URLFOR function, and call it from your snippet. Something like:
Visualforce code:
Skuid snippet code:
2. Call an Apex invocable method that accepts parameters from your Skuid snippet and does the redirect. Here's a doc on writing Apex invocable methods for your Skuid pages: https://docs.skuid.com/latest/en/skuid/salesforce/apex/apex-invocable-methods.html
Let me know if one of those options works for you!
Emily