{"id":1395,"date":"2020-07-24T11:09:01","date_gmt":"2020-07-24T11:09:01","guid":{"rendered":"https:\/\/staging.txtbox.in\/docs\/developers\/?post_type=lsvr_kba&#038;p=1395"},"modified":"2020-07-24T11:09:01","modified_gmt":"2020-07-24T11:09:01","slug":"send-bulk-sms-messages","status":"publish","type":"lsvr_kba","link":"https:\/\/staging.txtbox.in\/docs\/developers\/knowledge-base\/send-bulk-sms-messages\/","title":{"rendered":"Send Bulk SMS Messages"},"content":{"rendered":"\n<p>Follow the steps below to sending SMS messages in bulk for all records that correspond to a particular Contact object.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create a List of type&nbsp;<strong>smagicinteract__smsMagic__c<\/strong>.<\/li><li>Iterate the contact list.<\/li><li>Create an object of&nbsp;<strong>smagicinteract__smsMagic__c<\/strong>.<\/li><li>Assign fields to the object.<\/li><li>Iterate through and perform the SMSCallout to send the SMS.<\/li><li>Finally, use database.insert to insert the object list.<\/li><\/ol>\n\n\n\n<p>Here is some example code that sends bulk SMS messages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">List smsObjectList = new List();\nList  conList; \/\/List of contact populated from the visual force page or fetch from the database.\nString templateText = 'test SMS by Screen Magic';\nString senderId = 'smsMagic'; \/\/ Please replace the 'smsMagic' with your relevant sender ID.\nfor(Contact contact :conList){\n   smagicinteract__smsMagic__c smsObject = new smagicinteract__smsMagic__c();\n   if(contact.MobilePhone != null){\n \n     smsObject.smagicinteract__SenderId__c = senderId;\n     smsObject.smagicinteract__PhoneNumber__c = contact.MobilePhone;\n     smsObject.smagicinteract__Name__c = contact.Name;\n     smsObject.smagicinteract__ObjectType__c = 'Contact';\n     smsObject.smagicinteract__disableSMSOnTrigger__c = 1;\n     smsObject.smagicinteract__external_field__c =\n     smagicinteract.ApexAPI.generateUniqueKey();\n     smsObject.smagicinteract__SMSText__c = templateText;\n     smsObjectList.add(smsObject);\n   }\n}\n\/*\n * Note : When you are using pushSMSCallout method to send the SMS\n *        please make sure that smagicinteract__disableSMSOnTrigger__c\n *        should have value as 1.\n *\/\nString response = smagicinteract.ApexAPI.pushSMSCallout(smsObjectList);\nDatabase.insert(smsObjectList,false);<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Follow the steps below to sending SMS messages in bulk for all records that correspond to a particular Contact object. Create a List of type&nbsp;smagicinteract__smsMagic__c. Iterate the contact list. Create an object of&nbsp;smagicinteract__smsMagic__c. Assign fields to the object. Iterate through and perform the SMSCallout to send the SMS. Finally, use database.insert to insert the object [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"lsvr_kba_cat":[153],"lsvr_kba_tag":[],"class_list":["post-1395","lsvr_kba","type-lsvr_kba","status-publish","format-standard","hentry","lsvr_kba_cat-sms-magic-for-developers"],"_links":{"self":[{"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/lsvr_kba\/1395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/lsvr_kba"}],"about":[{"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/types\/lsvr_kba"}],"author":[{"embeddable":true,"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/comments?post=1395"}],"version-history":[{"count":1,"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/lsvr_kba\/1395\/revisions"}],"predecessor-version":[{"id":1396,"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/lsvr_kba\/1395\/revisions\/1396"}],"wp:attachment":[{"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/media?parent=1395"}],"wp:term":[{"taxonomy":"lsvr_kba_cat","embeddable":true,"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/lsvr_kba_cat?post=1395"},{"taxonomy":"lsvr_kba_tag","embeddable":true,"href":"https:\/\/staging.txtbox.in\/docs\/developers\/wp-json\/wp\/v2\/lsvr_kba_tag?post=1395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}