UpdateInstance Method

Sample Code for Updating a Lead using the UpdateInstance method of CampusNexu CRM Higher Education Foundation iService.

In the following sample code we will be updating the following Properties details of an existing Lead item, John Peter with Lead ID 76 in CampusNexus CRM.

  • Phone – 566-523-4373

  • Education Level - High School

  • Lead Category – High School

    The Lead Category Property is an enumerated Property. For this Property, you must pass the ID of the index of the enumerated value of this Property as the value. For example, the ID of the index of the High School enumerated value of the Lead Category Property is 1. You must pass 1 as the value for the Lead Category Property.

    For information on finding the ID of the index of an enumerated Property value, see Querying Main Database.

Sample Code for the UpdateInstance Method
public void UpdateLeadHEiService()
        {
            //Creating an Instance of SIS Connector iService
            SISConnectorWebService SISService = new SISConnectorWebService();

            //Setting the suppress message flag to true.
            SISService.SuppressMsgValue = new SuppressMsg();
            SISService.SuppressMsgValue.SuppressMsgFlag = true;

            //Generating the Username Token Information
            UsernameToken userToken = getUserToken("ParkerRoy", "password");

            //Associating the Username Token Information with the SIS Connector iService Instance
            SISService.RequestSoapContext.Security.Tokens.Add(userToken);
            SISService.RequireMtom = false;

            //Creating ObjectInformation Instance
            ObjectInformation objectData = new ObjectInformation();
            objectData.ObjectType = 20005; // Object type of Lead Object
            objectData.InstanceId = 76;    // Setting instance ID to 76

            //Initializing the PropertiesInformation list with required Information
            objectData.PropertiesInformation = new PropertyInformation[3]; // 3 properties are passed for lead creation.


            //Setting the values of the Phone Property of the Lead Object
            PropertyInformation propPhone = new PropertyInformation();
            propPhone.Id = 4810086;//ID of the Phone Property of the Lead Object.
            propPhone.Value = "566-523-4373";//Value of the Phone Property of the Lead Object.
            objectData.PropertiesInformation[0] = propPhone;

            //Setting the values of the PropertyInformation class for the Education Level Property of the Lead Object
            PropertyInformation propEducationLevel = new PropertyInformation();
            propEducationLevel.Id = 4810019; //ID of the Education Level Property of the Lead Object.
            propEducationLevel.Value = "1";//Instance ID of High School
            objectData.PropertiesInformation[1] = propEducationLevel;

            //Setting the values of the PropertyInformation class for the Lead Category Property of the Lead Object
            PropertyInformation propLeadCategory = new PropertyInformation();
            propLeadCategory.Id = 4810074; //ID of the Lead Category Property of the Lead Object.
            propLeadCategory.Value = "1"; // Index of the enumerated value of the Lead Category Property.
            objectData.PropertiesInformation[2] = propLeadCategory;

            //Intializing GeneralInfo structure
            GeneralInfo[] generalInfo = new GeneralInfo[2];
            generalInfo[0] = new GeneralInfo();
            generalInfo[0].KeyName = "updateReadOnly";
            generalInfo[0].KeyValue = "yes"; // Passing the value as yes to allow update to the read-only properties of the Lead Object.


            generalInfo[1] = new GeneralInfo();
            generalInfo[1].KeyName = "IgnoreMandatory";
            generalInfo[1].KeyValue = "no"; // Passing the value as no to ignore the unfilled mandatory properties check.

            //Declare the OperationInformation which provides details of Operation
            OperationInformation operationInfo = null;

            //Intializing ReturnStatus
            ReturnStatus returnStatus = new ReturnStatus();

            //Calling CreateInstance method for Lead Creation
            returnStatus = SISService.UpdateInstance(objectData, generalInfo, out operationInfo);

            if (returnStatus.StatusId != 0)
            {
                //Operation Failed, Handle Failure.
            }
        }