function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GraceWGraceW 

How to avoid creating the same instance of events ?

Hi,
      If I execute the following code multiple times, saleforce database is going to store the same event multiple times with the same ActivityDateTime. How can I avoid this? Is there any event field I need to set in order to achieve the goal?
     Thx!

 MessageElement[] event = new MessageElement[6];
                        event [0] = new MessageElement(new QName("WhoId"), leadid);
                        event [1] = new MessageElement(new QName("OwnerId"), spid);
                        event [2] = new MessageElement(new QName("Location"), "IBN");
                        event [3] = new MessageElement(new QName("Description"), "Demo of product");
                        event [4] = new MessageElement(new QName("ActivityDateTime"),  "2006-12-26T12:37:00Z");
                event [5] = new MessageElement(new QName("DurationInMinutes"), "60");
                           out.println("<br>New appointment created with the id : " + sfservice.setAppointment(event));

ClaiborneClaiborne

The only way I know is to perform a query with the same field entries in the Where clause. If you find a match, do not create a new event. If no match, create the event.

This is bit tedious, but it will prevent multiple events.

You also may want to update the event with new information on a partial match.

SuperfellSuperfell
If the data is coming from an external system and each row has its own key in that system, then you should be able to create an externalId custom field and use the upset call.