Workflow configuration

Workflow configuration

UPDATED 12-6-2022



How to check API Names for the user module:




1. Create a new workflow
2. Instant action should be a new function ->  WRITE YOUR OWN
3. Argument mapping should be as follows



4. The function should be as below:

Lead = zoho.crm.getRecordById("Leads",LeadID);
if(Lead.get("id") != null)
{
	LeadOwner = Lead.get("Owner");
	FirstName = ifnull(Lead.get("First_Name"),"");

	Owner = zoho.crm.getRecordById("users", LeadOwner.get("id"));
	
	AccountId = "";
	if (Owner.get("users") != null){
		AccountId = Owner.get("users").get(0).get("RC_Account_ID");
	}

	ExtensionId = ""; // Extension ID if needed (optional)
	FromNumber = ""; // If different from account phone number (optional)
	ToNumber = Lead.get("Mobile");
	MsgText = "Hi there " + FirstName + " testing it"; // TODO: Customize the message text

//Important - if you received the extension from the Zoho Marketplace the below line changes to mpmultiuserringcentralsmsmessaging.sendRcSms(AccountId,ExtensionId,FromNumber,ToNumber,MsgText);
resp = multiuserringcentralmessagingextension.sendRcSms(AccountId,ExtensionId,FromNumber,ToNumber,MsgText); info resp; }
5. Each user has to have their account ID in the user profile here:




7. You can find each users ACCOUNT ID in the RC Account Manager module, bottom of page:

 
IMPORTANT: In order for it to work, the super admin has to be added to each users RingCentral profile in the RC Account Manager module.

So more advanced deal - contact texting. 
void automation.send_RC_SMS_to_contact_of_deal(string dealID)
{
    // Fetch the deal record by its ID
    dealRecord = zoho.crm.getRecordById("Deals", dealID);

    // Check if the Contact lookup field is available in the deal record
    if(dealRecord.get("Contact_Name") != null)
    {
        // Get the Contact ID from the Deal
        contactId = dealRecord.get("Contact_Name").get("id"); 
        contactRecord = zoho.crm.getRecordById("Contacts", contactId); // Fetch the Contact record

        // Check if the contact exists and has an ID
        if(contactRecord.get("id") != null)
        {
            // Check if SMS_Opt_Out is false (unchecked)
            if(contactRecord.get("SMS_Opt_Out") == false)
            {
                contactFirstName = ifnull(contactRecord.get("First_Name"), "");
                contactMobile = contactRecord.get("Mobile");

                if(contactMobile != null)
                {
                    // Get the Deal Owner (optional based on your needs)
                    dealOwner = dealRecord.get("Owner");
                    ownerRecord = zoho.crm.getRecordById("users", dealOwner.get("id"));

                    // Retrieve the RC Account ID from the user (Owner) record
                    AccountId = "";
                    if (ownerRecord.get("users") != null)
                    {
                        AccountId = ownerRecord.get("users").get(0).get("RC_Account_ID");
                    }

                    // Define the extension ID, from number, and the message content
                    ExtensionId = ""; // Optional Extension ID
                    FromNumber = "";  // Optional From Number (use if different from account number)
                    MsgText = "Hi " + contactFirstName + ", just checking in to make sure you received my proposal. Let me know if you have any questions. - Matt Kakuk";

                    // Send the SMS using the correct API call
                    resp = multiuserringcentralmessagingextension.sendRcSms(AccountId, ExtensionId, FromNumber, contactMobile, MsgText);
                    info resp; // Log the response for debugging
                }
                else
                {
                    info "Contact does not have a mobile number.";
                }
            }
            else
            {
                info "Contact has opted out of SMS communication.";
            }
        }
        else
        {
            info "Contact record not found.";
        }
    }
    else
    {
        info "No contact associated with this deal.";
    }
}