Adding On-Click Javascript Button to Skuid for SMSMagic

  • 1
  • Question
  • Updated 2 years ago
  • Answered
We use SMS Magic (Screen Magic) to send text messages in our Org. I'm attempting to add the on-click javascript to the button, but am running into an issue. I've followed the steps in this thread:

https://community.skuid.com/skuid/topics/list_view_button_added_to_skuid_table

which is for the same app. However, the code in this version of the managed application is different. It requires this code:

{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/14.0/apex.js")} 
{!REQUIRESCRIPT('/resource/smagicinteract__smJQuery/js/jquery-1.10.2.js')} 
{!REQUIRESCRIPT('/resource/smagicinteract__smJQuery/js/jquery-ui-1.10.4.custom.min.js')} 
{!REQUIRESCRIPT("/resource/smagicinteract__sendSMSJS")} 

var packagePrefix = "smagicinteract__"; 
var recordType = 'PRC_Client__c'; 
var idToUpdate = '{!PRC_Client__c.Id}' 
var nameField = 'Name'; 
var mobileField = 'Phone_Number__c'; 
var optOutField = 'smagicinteract__SMSOptOut__c'; 
var optOutDefaultValue = 'yes'; 
var smsType = ''; 
var userId = '{!$User.Id}'; 
var elementIdVar = ''; 
var showUserDropDown = false; 
var dialogTitle = ''; 
var cssUrl = '{!URLFOR('/resource/smagicinteract__smJQuery/css/sm-theme/jquery-ui-1.10.4.custom.min.css')}'; 

sendSMS(recordType, idToUpdate, userId, nameField, mobileField, optOutField, optOutDefaultValue, smsType, elementIdVar, packagePrefix, showUserDropDown, dialogTitle, cssUrl);

Which does nothing but load a blank white page with the SF sidebar/header as long as the line:

var cssUrl = '{!URLFOR('/resource/smagicinteract__smJQuery/css/sm-theme/jquery-ui-1.10.4.custom.min.css')}';

Is included. Is there a way around this app causing an error by including this script?

Thanks,
Brad Smith
Photo of Brad Smith

Brad Smith

  • 80 Points 75 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Along the lines of the steps in the community post you linked to, you need to do the following:

1. Add a JavaScript Resource of Resource Type "External" to your Skuid Page for each of the following URL's:

/soap/ajax/14.0/apex.js
/resource/smagicinteract__sendSMSJS

2. Add a JavaScript Resource of Resource Type "Inline (Snippet)" to your Skuid Page called "sendSMS" with the following code:

var params = arguments[0];
var row = params.item ? params.item.row : params.row;

var packagePrefix = "smagicinteract__"; 
var recordType = 'PRC_Client__c'; 
var idToUpdate = row.Id;
var nameField = 'Name'; 
var mobileField = 'Phone_Number__c'; 
var optOutField = 'smagicinteract__SMSOptOut__c'; 
var optOutDefaultValue = 'yes'; 
var smsType = ''; 
var userId = skuid.utils.userInfo.userId; 
var elementIdVar = ''; 
var showUserDropDown = false; 
var dialogTitle = ''; 
var cssUrl = '/resource/smagicinteract__smJQuery/css/sm-theme/jquery-ui-1.10.4.custom.min.css';

sendSMS(recordType, idToUpdate, userId, nameField, mobileField, optOutField, optOutDefaultValue, smsType, elementIdVar, packagePrefix, showUserDropDown, dialogTitle, cssUrl);

3. Add a Page Title Button to your Page Title, or Row Action to your Table (depending on what you're trying to do) that runs a Snippet, with Snippet Name set to "sendSMS".
Photo of Brad Smith

Brad Smith

  • 80 Points 75 badge 2x thumb
Thanks, that did it. Much appreciated!