3 Replies Latest reply on Apr 30, 2020 2:50 PM by Casey Clayton

    Sample Process: Salesforce Account, Contact, Case to JSON & XML

    Casey Clayton Seasoned Veteran

      Hi Cloud Application Integration Fans and Followers,


      I wanted to share a Process Solution that demonstrated a few great techniques for data access and manipulation in a single use case.  By popular demand this article has been updated with new details and Assets that are compatible with IICS/CAI.


      Requirement: Create a Process that can take in a search type and search string to return selected data about every Salesforce Account that meets the criteria.  This includes information from the account record, as well as all related contact and case records, in a hierarchical way.  In addition to returning the response to the caller of the Web Service, the process can also generate an XML or JSON file.  This file is written to a folder on the Secure Agent.


      Things you will see

      • Creating a Process that can be triggered on-demand via a Web Service call (REST or SOAP)
      • Using an Assignment Step to query Salesforce for a list of Accounts using specified criteria (Id, Name, BillingState)
      • Querying for Related Records using the Id of the record being processed
      • Using nested sub-processes, "Applies To", and Iteration Rule functionality for Hierarchical List Processing
      • Using Process Objects to define and hold a copy of the field values you want to output.
      • Writing data to a file system in multiple formats (XML/JSON)
      • Use of a Milestone to avoid timeouts by returning message to Web Service Request while process continues to run


      Implementation Notes:

      • Imports into a Project in your IICS Cloud Application Integration named SFDCtoXMLJSON.
      • Returns response to Web Service caller by default
      • Assumes an existing Salesforce App Connection named "Salesforce" (Salesforce connection not included in Assets).
        • No custom fields were used in this sample, so it should work OOTB in with any Salesforce Org.
        • Changing Salesforce connection will require you to update Properties of all the processes
          • the Field Type for all Salesforce related input, output, and temp fields
          • the "Applies To" value for the subprocesses
      • DemoFileConnection is configured to write to a folder on secure agent called C:\Files\SFDCtoXMLJSON.  You must create this folder on the Secure Agent or modify the Event Target in DemoFileConnection to a different folder before publishing.
      • Does not dump all fields in Salesforce record, desired fields must be specified in the Process Objects and then mapped in the "Populate" assignment steps in the appropriate sub-process for that object must be modified to map.
      • Current design only returns Cases that are related via Contact to the Account.
      • Other objects may be added, but you must create a Process Object and Sub-process for each following the same pattern.


      Screenshot of Assets


      Inputs to Process RunAccountContactCaseToFile

      • inQueryType: [Values: Name, Id, BillingCity] specifies which field to use in Account Query
      • inQueryValue: search string that is appropriate for QueryType (e.g. "Core Care Technologies", "0010v00000MLxICAA1", "NY")
      • inWriteFile: [Values: Yes, No] tells the process to also write a file to the file system
      • inWriteFileType: [Values: XML, JSON] tells the process what kind of file format to write
      • inQuickReturn: [Values: Yes, No] tells the process whether or not to wait for all the data to be processed and returned as a response payload, use "Yes" if you are seeing timeouts when making calls to this service, File Write will still occur in background


      Here are screenshots of the Process being called using Postman


      Sample Response in Postman


      Files after running process twice, once for XML and once for JSON


      Sample XML File


      Sample JSON File


      Message was edited by: Casey Clayton