tags:

views:

470

answers:

1

I am developing an application using the CRM 4.0 web service interface and need to programatically create a phone call record and link it to an account record. I can see how to create the records but I am not sure how to link the phone call to the account. Any help would be much appreciated.

Thanks

Nigel

+5  A: 

You can't directly link an activity (like phone call) to an entity (like account). You must use the activityparty object to do it.
To do it follow these steps (I am assuming the account exists):

        phonecall newPhoneCall = new phonecall ();

        // Set the properties of the newPhoneCall.
        newPhoneCall.subject = "Test newPhoneCall";
        newPhoneCall.description = "New newPhoneCall";

        // Create the party sending and receiving the newPhoneCall.
        activityparty party = new activityparty();

        // Set the properties of Activityparty.
        party.partyid = new Lookup();
        party.partyid.type = EntityName.account.ToString();
        party.partyid.Value = existingAccount.accountId;

        // The party sends and receives the newPhoneCall.
        newPhoneCall.from = new activityparty[] { };
        newPhoneCall.to = new activityparty[] { party };

Then create the phone call activity as normal.

Robert MacLean