1

I have created a custom object in Salesforce named Call_c. There is already a standard object in Salesforce named Contact

There is a field named call_number_c__c in my Call_c and MobilePhone field in Contact object.

Using SOAP API in C#, when I am going to create a dynamic entry in Call_c object, at that time I want to query if my call_number_c__c matches with the MobilePhone of Contact object. If it matches, I want to create a relationship between Call_c and Contact. So when I see it in my Call_c object in SalesForce, it will show the name of contact associated with MobilePhone in Contact object. For this, I have created a lookup field parent_id__c in Call_c object with data-type Lookup(Contact) I can manually go in the Salesforce site and can associate the Contact with the entry in call, but how can I achieve the same using SOAP API. I really don't have any idea about how to implement this. This is similar to set_relationship method used in SugarCRM. Can anyone lead me in the right direction?

It would be very helpful to me if you can provide little code snippet and mechanism so I can move forward. Thanks!

1

In your C# code you just have to update the parent_id__c with the id of the contact you found a match for.

UPDATE

//code that will match and get the record from Contact object

//this will update the id of the relantionship
Call_c updatedCall = new Call__c();
updatedCall.Id = callId; //Point to an existing Call__c record to update
updatedCall.parent_id__c = matchedContact.Id;

SaveResult[] saveResults = binding.update(updatedCall);

See more examples at this documentation, on how to update more records, writing them in a try and catch exception, etc.

Hope it helps

5
  • Can you provide a little code-snippet or rough lines of code, so that I can indulge in it give a final touch??
    – YuDroid
    Jan 1 '15 at 12:44
  • Updated my answer Jan 1 '15 at 12:55
  • You saved my day buddy! Thanks! I will keep posting if I get any trouble again.. ;-)
    – YuDroid
    Jan 2 '15 at 6:08
  • I need one more doubt to be cleared. I have Leads module in my SalesForce. As I have put the parent_id__c field as lookup on Contact. What should I do if I want to relate this updatedCall with Lead as well? Do I need to create separate lookup field in Leads module as well? As per my requirement, I want that these two relationships be established in a single operation. Is it possible? Please suggest your thought about this.
    – YuDroid
    Jan 2 '15 at 6:19
  • Yes, you need to create a separate lookup relationship . I see no problem in them being updated at the same time. You might want to change the name of the lookup so you know that this is for contact and the other for lead. Jan 2 '15 at 10:13

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.