0

I have shared the Enterprise WSDL to an external System to create contact. In Contact , I have two custom field Country and State. These field are lookup to object called Location.

In order to create Contact , external system has to put the Salesforce ID in Country and state lookup. But, external System does not have these SF id and they don't want to query as well. It's something needs to be handled from SFDC side.

Please advice how can I manage this.

0

If the fields need to be populated and the external service will not populate them your only recourse would be to add a trigger and populate the fields yourself.

This would require you to have access to the information needed to get the correct values from each object. I am assuming that for country the external service can populate a country for you on the contact object, same with state?

Something like this mock up

trigger populate_fields on Contact(before insert){

 Map<String,ID> ctry = New Map<String,ID>();

 for(Contact c : trigger.new){
        if(c.Country != null)
           ctry.put(c.Country,null);

 }


for(Country__c c : [Select ID From Country__c Where Name IN :ctry.keySet()]){

       ctry.put(c.name,c.id);

}

for(Contact c : trigger.new){

   c.Country__c = ctry.get(c.Country);
   if(c.Country__c == null)
        c.addError('Unable to find associated Country');

   }

}
3
  • thanks a lot Eric. Do I need to create field for what external Service passing. I mean..let's take an example of AccountId Oct 31 '14 at 3:13
  • I am not clear on what you are asking
    – Eric
    Oct 31 '14 at 3:37
  • Hi Eric, sorry for the late reply. Just a qq, in dataloader if we provide teh external field of the related object, then we can give the values in the field instead of giving actual SFDC ID. Can't we do the same here.. I have posted a question for this .. Please have a look. Thanks.salesforce.stackexchange.com/questions/54966/… Nov 3 '14 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.