Configure Salesforce Workflows for CXone Agent Embedded

You can configure Search, Custom Create, and Standard Create workflows for Salesforce and CXone Agent Embedded. These workflows search or create Salesforce records, also called objects. This is the back end configuration of dynamic data mapping.

Workflow Type

Description

Workflows

Search Search workflows scan Salesforce for records that are applicable to the interaction the agent is handling. Search for ANI
Custom Search
Custom Create Custom Create workflows create any record type with both standard and custom fields. Create Custom Record
Standard Create

Standard Create workflows create standard Salesforce records with their standard data fields. The SNIPPET payload of these workflows must include the standard fields and only those fields.

Create Account
Create Case
Create Contact
Create Lead
Create Opportunity
Create Work Order

Configure Search Workflows

There are two Search workflows: Search for ANI and Custom Search.

Configure the Search for ANI Workflow

The Search for ANI workflow uses the ANIClosed Also known as caller ID. Listed phone number of an incoming voice call. from the ACD to search all standard phone fields for matching records.

Use this example script.

  1. In Studio, open the script where you want to configure the Search for ANI workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC searchInput
    searchInput.workflowInput.phoneNumber = "{ANI}"
    						
    ASSIGN searchJson = "{searchInput.asjson()}"
    		
  5. Save your script.

  6. You can test your script by simulating an interaction in Studio.

Configure the Custom Search Workflow

The Custom Search workflow allows you to search for one or more Salesforce records. They also allow you to search multiple fields and variables within a specified record. You can connect different search requirements using Salesforce operators.

This workflow supports these Salesforce records:

  • Account

  • Case

  • Contact

  • Lead

  • Opportunity

  • Work Order

Use this example script.

  1. In Studio, open the script where you want to configure the Custom Search workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC searchInput
    
    DYNAMIC payload					
    payload.entity = "[API Name]"
    payload.filter = "[fieldName][operator]'{variable}'"
    
    searchInput.workflowInput.search = payload
    
    ASSIGN searchJson = "{searchInput.asjson()}"
    		
  5. Change the value of the payload.entity attribute to the API name for the record you want to search. For example, payload.entity = "account". This is case-sensitive.

  6. Change the value of the payload.filter attribute. This determines the search filter criteria for the record. For example, payload.filter = "phone='{ANI}'".

    1. Change [fieldName] to the name of the field you want to use to search, such as phone. This is case-sensitive.

    2. Change [operator] to the Salesforce operator you want to use. A full list of Salesforce operators can be found in the Salesforce documentation . This is case-sensitive.

    3. Change {variable} to the variable you want to assign to the field. This is case-sensitive.

  7. To add additional search filters, use a Salesforce operator between the filters. For example:

    
    payload.filter = "phone='{ANI}'AND customer_number_c='{CustomerNumber}'"
    		

    This example script shows how this works.

  8. Save your script.

  9. You can test your script by simulating an interaction in Studio.

Configure Custom Create Workflows

Custom Create workflows allow you to configure a SNIPPET payload to create any type of Salesforce record, standard or custom. They also allow you to populate any field type, standard or custom. For example, you could create an Account record with some of the standard fields from that record type, as well as your own custom fields.

This is the recommended method to create Salesforce records.

Configure the Create Custom Record Workflow (Previously Create Entity)

The Create Custom Record workflow creates any type of Salesforce record, standard or custom. This record can display standard and custom data fields. The fields must contain text, numbers, or variables. Binded fields are most often populated by search results or lists of options, but you can configure this workflow to add hard-coded data to a binded field.

Use this example script.

This was previously called the Create Entity workflow.

  1. In Studio, open the script where you want to configure the Create Custom Record workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createPayload
    DYNAMIC createDataArray
    						
    DYNAMIC item1
    item1.field = "[API name]"
    item1.value = "[variable]"
    DYNAMIC item2
    item2.field = "[API name]"
    item2.value = "[variable]"
    DYNAMIC item3
    item3.field = "[API name]"
    item3.value = "[variable]"
    
    createPayload.tablename = "[record type]"
    createDataArray[1] = item1
    createDataArray[2] = item2
    createDataArray[3] = item3
    
    createPayload.data = createDataArray
    						
    createPayload.pinnedRecord = "[true or false]"						
    										
    DYNAMIC createPayload
    createPayload.workflowInput = createPayload
    						
    ASSIGN createJson = "{createPayload.asjson()}"
    		

    You must include each of those lines.

  5. Change the values of the attributes listed below. Any of these can be hard-coded, a variable, or a combination of these. Use a variable if you want the value to update for each interaction.

    1. Change the value of item1.field to the first field you want to display. Change item1.value to the value of that field. For example:

      
      item1.field = "Status"
      item1.value = "New"
      		
    2. Change the value of item2.field to the second field you want to display. Change item2.value to the value of that field. For example:

      
      item2.field = "Origin"
      item2.value = "Phone"
      		
    3. Change the value of item3.field to the third field you want to display. Change item3.value to the value of that field. For example:

      
      item3.field = "CXone_Contact_ID_c"
      item3.value = "{ContactID}"
      		
  6. Change the value of the createPayload.tablename attribute to the API name for the record you want to use. For example, createPayload.tablename = "account". This is case-sensitive.

  7. Change the value of the createPayload.pinnedRecord attribute to either true or false. When set to true, the created record will display to agents in the Current Interactions section of the customer card. If set to false, it will display in the Recent Interactions section of the customer card. If you do not include this attribute in the payload, it will be assumed as false.
  8. To add additional fields:

    1. Create additional item dynamic data objects after item3.value. Follow this format:

      
      DYNAMIC item#
      item#.field = "[Field #]"
      item#.value = "[Field # Value]"
      		

      The number (#) needs to increment by one with each additional dynamic data object you add. For example, item4, item5, and so on.

    2. Create additional data arrays after createDataArray[3]. Follow this format:

      
      ASSIGN createDataArray[#] = item#
      		

      The number (#) needs to increment by one with each additional item you add to the array. For example, createDataArray[4], createDataArray[5], and so on.

  9. Save your script.

  10. You can test your script by simulating an interaction in Studio.

Configure Standard Create Workflows

Standard Create workflows allow users to search standard Salesforce records inside Salesforce.

You cannot add or delete fields in the SNIPPET payload of Standard Create workflows. If you add or delete fields, the workflow will fail and the record won't be created. To create a standard or custom record with the fields you want, use the Create Custom Record workflow.

Configure the Create Account Workflow

  1. In Studio, open the script where you want to configure the Create Account workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createAccount
    createAccount.accountName = "[account name]"
    createAccount.accountType = "[account type]"
    createAccount.accountPhone = "{ANI}"
    						
    DYNAMIC createAccountPayload
    createAccountPayload.workflowInput = createAccount
    ASSIGN createAccountJson = "{createAccountPayload.asjson()}"
    		

    You must include each of those lines. If you want a field to stay blank, you can use a null value (""). For example, createAccount.accountType = "". However, you cannot assign a null value to createAccount.accountName.

  5. Change the value of the createAccount.accountName attribute to the name of the account. For example, createAccount.accountName = "Elinor from Classics, Inc.". This value can be hard-coded, a variable, or a combination of these. Use a variable if you want this value to update for each interaction.

  6. Change the value of the createAccount.accountType attribute to the type of account. For example, createAccount.accountType = "Book Orders - Chat". This value can be hard-coded, a variable, or a combination of these. Use a variable if you want this value to update for each interaction.

  7. Save your script.

  8. You can test your script by simulating an interaction in Studio.

Configure the Create Case Workflow

  1. In Studio, open the script where you want to configure the Create Case workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createCase
    createCase.entityType = "[Contact or Account]"
    createCase.name = "[case name]"
    createCase.phone = "{ANI}"
    createCase.email = "[case email]"
    createCase.company = "[case company]"
    createCase.status = "[case status]"
    createCase.caseReason = "[reason for case]"
    createCase.caseOrigin = "{SKILL}"
    createCase.priority = "[low, medium, high, or critical]"
    createCase.description = "New Record - {CONTACTID}"
    createCase.internalComments = "[internal comments]"
    						
    DYNAMIC createCasePayload
    createCasePayload.workflowInput = createCase
    ASSIGN createCaseJson = "{createCasePayload.asjson()}"
    		

    You must include each of those lines. If you want a field to stay blank, you can use a null value (""). For example, createCase.name = "". However, you cannot assign a null value to createCase.entityType or createCase.status.

  5. Change the values of the attributes. Any of these can be hard-coded, a variable, or a combination of these. Use a variable if you want the value to update for each interaction.

    1. Change the value of the createCase.entityType attribute to Contact or Account. For example, createCase.entityType = "Contact".

    2. Change the value of the createCase.name attribute to the case's name. For example, createCase.name = "Elinor Dashwood's Case".

    3. Change the value of the createCase.email attribute to the email address for the case. For example, createCase.email = "elinor.dashwood@classics.com".

    4. Change the value of the createCase.company attribute to the organization for the case. For example, createCase.company = "Classics, Inc.".

    5. Change the value of the createCase.status attribute to the case's status. For example, createCase.status = "New".

    6. Change the value of the createCase.caseReason attribute to the reason for the case. For example, createCase.caseReason = "Shipping problems".

    7. Change the value of the createCase.priority attribute to low, medium, high, or critical. For example, createCase.priority = "low".

    8. Change the value of the createCase.internalComments attribute to a description of the case for internal use. For example, createCase.internalComments = "Elinor's book order is missing. It might have a wrong shipping address.".

  6. Save your script.

  7. You can test your script by simulating an interaction in Studio.

Configure the Create Contact Workflow

  1. In Studio, open the script where you want to configure the Create Contact workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createContact
    createContact.firstName = "[first name]"
    createContact.lastName = "[last name]"
    createContact.homePhone = "{ANI}"
    createContact.mobilePhone = "[mobile phone number]"
    createContact.businessPhone = "{ANI}"
    createContact.email = "[email address]"
    createContact.contactDescription = "[description of contact]"
    
    DYNAMIC createContactPayload
    createContactPayload.workflowInput = createContact
    
    ASSIGN createContactJson = "{createContactPayload.asjson()}"
    		

    You must include each of those lines. If you want a field to stay blank, you can use a null value (""). For example, createContact.firstName = "". However, you cannot assign a null value to createContact.lastName.

  5. Change the values of the attributes. Any of these can be hard-coded, a variable, or a combination of these. Use a variable if you want the value to update for each interaction.

    1. Change the value of the createContact.firstName attribute to the contact's first name. For example, createContact.firstName = "Elinor".

    2. Change the value of the createContact.lastName attribute to the contact's last name. For example, createContact.lastName = "Dashwood".

    3. Change the value of thecreateContact.mobilePhone attribute to the contact's mobile phone number. For example, createContact.mobilePhone = "1234567890".

    4. Change the value of the createContact.email attribute to the contact's email address. For example, createContact.email = "elinor.dashwood@classics.com".

    5. Change the value of the createContact.contactDescription attribute to a description of the contact. For example, createContact.contactDescription = "Elinor needs help with her book order".

  6. Save your script.

  7. You can test your script by simulating an interaction in Studio.

Configure the Create Lead Workflow

  1. In Studio, open the script where you want to configure the Create Lead workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createLead
    createLead.firstName = "[first name]"
    createLead.lastName = "[last name]"
    createLead.company = "[company]"
    createLead.phone = "{ANI}"
    createLead.email = "[email address]"
    createLead.website = "[website URL]"
    createLead.description = "New Record - {CONTACTID}"
    createLead.status = "[status of lead]"
    						
    DYNAMIC createLeadPayload
    createLeadPayload.workflowInput = createLead
    ASSIGN createLeadJson = "{createLeadPayload.asjson()}"
    		

    You must include each of those lines. If you want a field to stay blank, you can use a null value (""). For example, createLead.firstName = "". However, you cannot assign a null value to createLead.lastName, createLead.company, or createLead.status.

  5. Change the values of the attributes. Any of these can be hard-coded, a variable, or a combination of these. Use a variable if you want the value to update for each interaction.

    1. Change the value of the createLead.firstName attribute to the lead's first name. For example, createLead.firstName = "Elinor".

    2. Change the value of the createLead.lastName attribute to the lead's last name. For example, createLead.lastName = "Dashwood".

    3. Change the value of the createLead.company attribute to the lead's organization. For example, createLead.company = "Classics, Inc.".

    4. Change the value of the createLead.email attribute to the lead's email address. For example, createLead.email = "elinor.dashwood@classics.com".

    5. Change the value of the createLead.website attribute to the lead's website. For example, createLead.website = "classics.com".

    6. Change the value of the createLead.status attribute to the lead's status. For example, createLead.status = "New".

  6. Save your script.

  7. You can test your script by simulating an interaction in Studio.

Configure the Create Opportunity Workflow

  1. In Studio, open the script where you want to configure the Create Opportunity workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createOpportunity
    createOpportunity.name = "[opportunity name]"
    createOpportunity.description = "New Record - {CONTACTID}"
    createOpportunity.stageName = "[stage of opportunity]"
    createOpportunity.closeDate = "[YYYY-MM-DD]"
    						
    DYNAMIC createOpportunityPayload
    createOpportunityPayload.workflowInput = createOpportunity
    ASSIGN createOpportunityJson = "{createOpportunityPayload.asjson()}"
    		

    You must include each of those lines. If you want a field to stay blank, you can use a null value (""). For example, createOpportunity.description = "". However, you cannot assign a null value to createOpportunity.name, createOpportunity.stageName, or createOpportunity.closeDate.

  5. Change the values of the attributes. Any of these can be hard-coded, a variable, or a combination of these. Use a variable if you want the value to update for each interaction.

    1. Change the value of the createOpportunity.name attribute to the name of the opportunity. For example, createOpportunity.name = "Classics, Inc. Elinor".

    2. Change the value of the createOpportunity.stageName attribute to the stage of the opportunity. For example, createOpportunity.stageName = "New".

    3. Change the value of the createOpportunity.closeDate attribute to the date the opportunity closed. For example, createOpportunity.closeDate = "2024-01-31".

  6. Save your script.

  7. You can test your script by simulating an interaction in Studio.

Configure the Create Work Order Workflow

  1. In Studio, open the script where you want to configure the Create Work Order workflow.

  2. If you haven't already, add a SNIPPET action after BEGIN and before the Workflow Execute action.

  3. Double-click the SNIPPET action on the script canvas.

  4. Copy each of the following lines of code and paste them into the Text View tab of the Editor window.

    
    DYNAMIC createWorkOrder
    createWorkOrder.description = "New Record - {CONTACTID}"
    createWorkOrder.startDate = "[YYYY-MM-DD]"
    createWorkOrder.endDate = "[YYYY-MM-DD]"
    createWorkOrder.subject = "New Record"
    createWorkOrder.status = "[status]"
    createWorkOrder.priority = "[low, medium, high, or critical]"
    createWorkOrder.duration = "[number of minutes or hours]"
    
    DYNAMIC createWorkOrderPayload
    createWorkOrderPayload.workflowInput = createWorkOrder
    ASSIGN createWorkOrderJson = "{createWorkOrderPayload.asjson()}"
    		

    You must include each of those lines. If you want a field to stay blank, you can use a null value (""). For example, createWorkOrder.description = "".

  5. Change the values of the attributes. Any of these can be hard-coded, a variable, or a combination of these. Use a variable if you want the value to update for each interaction.

    1. Change the value of the createWorkOrder.startDate attribute to the date the work order began. For example, createWorkOrder.startDate = "2024-01-30".

    2. Change the value of the createWorkOrder.endDate attribute to the date the work order ended. For example, createWorkOrder.endDate = "2024-01-31".

    3. Change the value of the createWorkOrder.status attribute to the status of the work order. For example, createWorkOrder.status = "New".

    4. Change the value of the createWorkOrder.priority attribute to low, medium, high, or critical. For example, createWorkOrder.priority = "low".

    5. Change the value of the createWorkOrder.duration attribute to the number of minutes or hours it took to complete the work order. For example, createWorkOrder.duration = "02".

  6. Save your script.

  7. You can test your script by simulating an interaction in Studio.