Category: xml

Salesforce Integration with SOAP API – Part 9 – Upsert operation using Java program

Preface – This post is part of “Salesforce Integration with SOAP API” series.In today’s post, I will explain how you can do Upsert operation using SOAP API and Java Program. Before that we should know what is so special about Upsert? Upsert will allow you to create a new record or update the existing record. Now I am sure you have this question is mind – “How Salesforce will know that the record is already there in the system?”, right!!!! Good. The answer is that you can pass the custom field which will be used to determine the presence of the existing record. So easy!!!It is always recommended to use upsert() rather that create() because of the obvious reason i.e. upsert() will eliminate the chance of creating duplicate record in the system.Syntax -UpsertResult[] = connection.upsert(String externalIdFieldName, sObject[] sObjects);Important point – Note: I have written a helper class which I am using to connect to Salesforce using Enterprise WSDL. To know more about that, please refer my previous post @ Salesforce Integration with SOAP API – Part 4 – Java program for connecting to Salesforce using SOAP API and Enterprise WSDLBelow is the Java program – UpsertOperation.javaimport com.sforce.soap.enterprise.EnterpriseConnection;import com.sforce.soap.enterprise.Error;import com.sforce.soap.enterprise.UpsertResult;import com.sforce.soap.enterprise.sobject.Account;import com.sforce.soap.enterprise.sobject.SObject;import;public class UpsertOperation { private EnterpriseConnection enterpriseConnection; private UpsertOperation(){ setEnterpriseConnection(ConnectionHelper.doConnect()); } public static void main(String[] args) { UpsertOperation upsertOperation = new UpsertOperation(); upsertOperation.doUpsertOperation(); } private void doUpsertOperation(){ SObject[] allUpserts = new Account[2]; //Create an Account...

Read More

Salesforce Integration – Creating XML Request using DOM + Custom Settings

Recently I got a requirement from one of my customer where I need to create the XML request and pass the same to a third party application using SOAP protocol. Initially I though it is very easy to do with Apex DOM APIs, but then I came to know that the other party (developer from that Third Party application) change their application quite frequently and as a result they need XML response in a different structure everytime they made some changes. Definitely my customer was very much irritated with this as they need to do code changes every time the other party do the change. So the important part of the requirement was to design something or do something so that with minimum (preferably no code change) changes Salesforce admin can handle the request from other party.Definitely quite a good challenge. Then after some discussion with the other party and Salesforce admin, I designed the application. The most complex part was how to create the XML Request dynamically(without any code change from Salesforce side) with new XML structure requirement.In this post, I will explain how I implemented the logic of creating XML Request with the help of Custom Settings. Yes, you are correct. Custom Settings is so powerful and important that you can play with it in many different ways and this post is one of the way.Let’s get...

Read More

Earlier Posts

  • 2024 (32)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)