locked
Create phone call using web services problem RRS feed

  • Question

  • Hello,

    I'm trying to create a phonecall and assign the from and to attributes:

    Entity phone = new Entity("phone");
    phone.attribute["subject"] = "hello";
    phone.attribute["to"] = new EntityReference("systemuser", new Guid("xxx"));
    phone.attribute["from"] = new EntityReference("systemuser", new Guid("xxx"));
    phone.attribute["regardingobjectid"] = new EntityReference("account", new Guid("xxx"));

    After added the record, regardingobjectid is completed but not FROM and TO.

    Thank you in advance for your support.
    Regards,

     

    Wednesday, December 18, 2013 11:03 AM

Answers

  • Hi,
    "to" and "from" attributes are activityparty, not entityreference.

    You need to create them as activityparty, you can start from this example:

    Entity toParty = new Entity("activityparty");
    toParty["partyid"] = new EntityReference("systemuser", new Guid("xxx"));
    
    Entity fromParty = new Entity("activityparty");
    fromParty["partyid"] = new EntityReference("systemuser", new Guid("xxx"));
    
    phone["to"] = new EntityCollection(new [] { toParty });
    phone["from"] = new EntityCollection(new [] { fromParty });


    My blog: www.crmanswers.net - Rockstar 365 Profile


    • Proposed as answer by Guido PreiteMVP Wednesday, December 18, 2013 12:05 PM
    • Edited by Guido PreiteMVP Wednesday, December 18, 2013 12:07 PM
    • Marked as answer by KMAREC Wednesday, December 18, 2013 1:05 PM
    Wednesday, December 18, 2013 12:05 PM

All replies

  • Please check this code

     

      OrganizationService.OrganizationServiceClient client = GetOrganizationService("OrgName"); //This method adds bindings dynamically to service
                    client.ClientCredentials.Windows.ClientCredential.Domain = "Domain";
                    client.ClientCredentials.Windows.ClientCredential.UserName = "User";
                    client.ClientCredentials.Windows.ClientCredential.Password = "Password";

                   

                   /// My request to create record starts here/////////////////////////

    OrganizationRequest req = new OrganizationRequest() { RequestName = "Create" };
                    Entity entity = new Entity();
                    entity.LogicalName = "salesorder";

                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    // Before Using Lookup or EntityReference  we have to add KnownTypeAttribute for Entity class in Reference.cs 
                    // Example : I have added following lines of code befor entity class to make this work.
                    // [System.Runtime.Serialization.KnownTypeAttribute(typeof(OrgDiscovery.OrganizationService.EntityReference))]
                    // [System.Runtime.Serialization.KnownTypeAttribute(typeof(OrgDiscovery.OrganizationService.OptionSetValue))]
                    // public partial class Entity : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                    EntityReference cust = new EntityReference();
                    cust.LogicalName = "contact";
                    cust.Id = new Guid(ddlCustomer.SelectedValue.ToString());


                    EntityReference curreny = new EntityReference();
                    curreny.LogicalName = "transactioncurrency";
                    curreny.Id = new Guid(ddlCurrency.SelectedValue.ToString());

                    EntityReference priselist = new EntityReference();
                    priselist.LogicalName = "pricelevel";
                    priselist.Id = new Guid(ddlPriceList.SelectedValue.ToString());

                    KeyValuePair<string, object> attOrderId = new KeyValuePair<string, object>("new_orderid", txtOrderId.Text);
                    KeyValuePair<string, object> attCustomer = new KeyValuePair<string, object>("customerid", cust);
                    KeyValuePair<string, object> attPriseList = new KeyValuePair<string, object>("pricelevelid", priselist);
                    KeyValuePair<string, object> attCurrency = new KeyValuePair<string, object>("transactioncurrencyid", curreny);
                    entity.Attributes = new OrganizationService.AttributeCollection();
                    entity.Attributes.Add(attOrderId);
                    entity.Attributes.Add(attCustomer);
                    entity.Attributes.Add(attPriseList);
                    entity.Attributes.Add(attCurrency);
                    Guid orderid = client.Create(entity);


    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.


    Wednesday, December 18, 2013 11:46 AM
  • Hi,
    "to" and "from" attributes are activityparty, not entityreference.

    You need to create them as activityparty, you can start from this example:

    Entity toParty = new Entity("activityparty");
    toParty["partyid"] = new EntityReference("systemuser", new Guid("xxx"));
    
    Entity fromParty = new Entity("activityparty");
    fromParty["partyid"] = new EntityReference("systemuser", new Guid("xxx"));
    
    phone["to"] = new EntityCollection(new [] { toParty });
    phone["from"] = new EntityCollection(new [] { fromParty });


    My blog: www.crmanswers.net - Rockstar 365 Profile


    • Proposed as answer by Guido PreiteMVP Wednesday, December 18, 2013 12:05 PM
    • Edited by Guido PreiteMVP Wednesday, December 18, 2013 12:07 PM
    • Marked as answer by KMAREC Wednesday, December 18, 2013 1:05 PM
    Wednesday, December 18, 2013 12:05 PM