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:

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!

Brad,
A few things you might try:

  1. Define a function in your Visualforce code via a tag that uses the URLFOR function, and call it from your snippet. Something like:
// EXAMPLE CODE ONLY. THIS SNIPPET IS NOT COMPLETE.

// Get all params needed from Skuid models...
var params = {sourceId, crl};

// Add additional params here as needed

// Call custom redirect function from our VF page if it exists.
// Note that this will only run if your Skuid page is placed in a Visualforce page with a customSkuidDocusignRedirect function defined
if (!!customSkuidDocusignRedirect) customSkuidDocusignRedirect(params);
  1. 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