Send SMS using APEX API

July 04, 2014

Send SMS

A developer can send SMS using API. For that he needs to follow the steps mentioned below:

  1. Create the object of smagicinteract__smsMagic__c (for Interact package).
  2. Now assign required fields to the object.
  3. Make the callout to send the SMS.
  4. Now call SOQL insert to insert the value into the Salesforce org.
The sample code for sending SMS is given below for SMS Magic Interact (This is just sample code & User can edit it according to the requirements)
List <smagicinteract__smsmagic__c>;
smsObjectList = new List <smagicinteract__smsmagic__c>();
String senderId = 'smsMagic';
String templateText = 'test SMS by Screen Magic'; // you can fetch the template text by querying the record on smagicinteract__SMS_Template__c object
smagicinteract__smsMagic__c smsObject = new smagicinteract__smsMagic__c();
smsObject.smagicinteract__SenderId__c = senderId;
smsObject.smagicinteract__PhoneNumber__c = contact.MobilePhone;
smsObject.smagicinteract__Name__c = contact.Name; // records name
smsObject.smagicinteract__ObjectType__c = 'Contact'; // record type
smsObject.smagicinteract__disableSMSOnTrigger__c = 0; // this field either be 0 or 1, if you specify the value as 1 then sms will not get send but entry of sms will get create under SMS History object
smsObject.smagicinteract__external_field__c = smagicinteract.ApexAPI.generateUniqueKey();
smsObject.smagicinteract__SMSText__c = templateText;

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>