General Discussion

  • 1.  Tech Talk Implementation - Salesforce Update Query

    Posted 10-17-2024 10:00

    A common question from customers setting up or expanding their integration with Salesforce and TrueContext is how to use a single destination to both create and update an object in Salesforce.

    In this example, I will focus on work orders, but the same methods apply to any object. The key is configuring your Update Query to check for the existing object to update; if it does not exist, it will create a new one. If you've tried this before, you may have met the error: “There was an error with the Salesforce API call: SOQL statements cannot be empty or null.” The error shows what went wrong, and I'll explain how to resolve it.

    Salesforce Destination: Update Query

    The Update Query tab in your Salesforce destination defines the conditions under which a record is updated or created. Our documentation explains several options, but I’ll use “Update if exists, otherwise create new” for this example.

    When building forms for Salesforce integration, include all relevant Salesforce IDs to update the records in your data source. For instance, if updating an account, pull in the AccountId; for contacts, include the ContactId. In this case, I'll pull in the WorkOrderId into my form (note that all Salesforce IDs are case-sensitive). In the form, my Workorder ID is called WOID and here is a simple example of the destination that I am using with this:

    I am using the Workorder ID to check for matches and if it finds a workorder with the same ID as the one in the form it will update that. If a match is found, it will pass the Description, Priority, and Subject to update the record. If no workorder is found with that ID, it will create a new workorder with those same data points.

    The Form

    In the form, you can't leave the WOID question blank, even when creating a new work order. Salesforce needs a valid 18-character ID; passing a blank value will cause the entire destination to fail with the earlier mentioned error.

    To avoid this, use Conditional Logic or set a default value for the WOID question. For example, you can set it to “111111111111111111” (18 ones), which is guaranteed to be invalid in Salesforce. With the default value in place, you can use a dropdown to select an existing work order, which will populate the WOID question with the correct Work Order ID.

    Using this technique will help you avoid creating more destinations than you need to and ultimately create a very flexible workflow that will keep all your data in Salesforce up to date as the people in the field are working through their workflows.



    ------------------------------
    Ian Chamberlain
    Solutions Architect
    TrueContext
    ------------------------------


  • 2.  RE: Tech Talk Implementation - Salesforce Update Query

    Adopter
    Posted 10-17-2024 16:04

    Thank you Ian! This idea is exactly what we needed. I can confirm that the 18-character 1's work perfectly in creating a new WO while also allowing an override of an existing WO in the dispatch. This allows me to have a single destination for the work order to either create a new one or update an existing work order. We have several salesforce cascading destinations built off of this first one with the work order, so without being able to combine create/update into 1 destination, we would have needed a TON of duplicate salesforce destinations depending on every possible variable. Thank you again!!!



    ------------------------------
    Lisa Zido
    Technical Systems Administrator
    GOJO Industries Inc.
    OH
    ------------------------------



  • 3.  RE: Tech Talk Implementation - Salesforce Update Query

    Staff
    Posted 10-18-2024 09:24

    You can find all of our Salesforce integration info in this section of the Product Documentation Portal: Salesforce Integration Overview



    ------------------------------
    Karen Cann
    Technical Communications Manager
    TrueContext
    ------------------------------



Reminder: Content posted to our Community is public content.  Please be careful not to post Intellectual Property that you do not have permission to share.  For more information please refer to our Terms Of Use