CreateInstance Method

Sample Code for creating a Lead using the CreateInstance method of CampusNexus CRM Higher Education Foundation iService.

In the following sample code we will be creating a Lead item in CampusNexus CRM with the following Lead Object Properties details:

  • Name - John Peter

  • Campus - Lake District

  • Team - Lake District

  • E-mail – John@gmail.com

  • SSN - 323-54-9867

  • Phone – 566-523-4352

  • Method of contact – Walk–In

    The Method of contact 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 Walk-In enumerated value of the Method of contact Property is 4. You must pass 4 as the value for the Method of contact Property.

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

Note Note

For the Campus and Team values of a Lead, you must pass the IDs of the SIS Team Property that is mapped with the CampusNexus CRM Team Property.

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

            //Setting the value of the SuppressMsgFlag 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 with the HE iService instance
            SISService.RequestSoapContext.Security.Tokens.Add(userToken);
            SISService.RequireMtom = false;

            //Creating an instance of the ObjectInformation Class
            ObjectInformation objectData = new ObjectInformation();

             //Initializing the values of the ObjectInformation class
            objectData.ObjectType = 20005; // 20005 is the Object type of the Lead Object
            objectData.InstanceId = -1;    // Instance ID must be set to -1 when an Object item is created.

            //Initializing the PropertiesInformation list with required Information
            objectData.PropertiesInformation = new PropertyInformation[7]; // 7 Properties are passed for creating a Lead item

            //Setting the values of the PropertyInformation class for the Name Property of the Lead Object            
            PropertyInformation propName = new PropertyInformation();
            propName.Id=4800002; //ID of the Name Property of the Lead Object.
            propName.Value="John Peter";//Value of the Name Property of the Lead Object.
            objectData.PropertiesInformation[0] = propName;

            //Setting the values of the PropertyInformation class for the Campus Property of the Lead Object
            PropertyInformation propCampus = new PropertyInformation();
            propCampus.Id=4810069; //ID of the Campus Property of the Lead Object.
            propCampus.Value="101"; // ID of the SIS Team that is mapped with the Lake District Campus in Talisma CRM.
            objectData.PropertiesInformation[1] = propCampus;

            //Setting the values of the PropertyInformation class for the Team Property of the Lead Object

            PropertyInformation propTeam = new PropertyInformation();
            propTeam.Id=4800005; //ID of the Team Property of the Lead Object.

            propTeam.Value="101"; // ID of the SIS Team that is mapped with the Lake District Team in Talisma CRM.

            objectData.PropertiesInformation[2] = propTeam;

            //Setting the values of the PropertyInformation class for the E-mail Property of the Lead Object

            PropertyInformation propEmail = new PropertyInformation();
            propEmail.Id=4810065; //ID of the E-mail Property of the Lead Object.
            propEmail.Value="john@gmail.com";//Value of the E-mail Property of the Lead Object.
            objectData.PropertiesInformation[3] = propEmail;

            //Setting the values of the PropertyInformation class for the SSN Property of the Lead Object
            PropertyInformation propSSN = new PropertyInformation();
            propSSN.Id=4810090; //ID of the SSN Property of the Lead Object.
            propSSN.Value="323-54-9867"; // Value of the SSN Property of the Lead Object.
            objectData.PropertiesInformation[4] = propSSN;

            //Setting the values of the PropertyInformation class for 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-4352"; //Value of the Phone Property of the Lead Object.
            objectData.PropertiesInformation[5] = propPhone;

            //Setting the values of the PropertyInformation class for the Method of contact Property of the Lead Object. 
            PropertyInformation propMethodOfContact = new PropertyInformation();
            propMethodOfContact.Id=4810075; //ID of the Method of contact Property of the Lead Object.

            propMethodOfContact.Value="4";// Index of the enumerated value of the Method of Contact Property.
            objectData.PropertiesInformation[6] = propMethodOfContact;

            //Intializing the GeneralInfo Structure
            GeneralInfo[] generalInfo= new GeneralInfo[2];
            generalInfo[0] = new GeneralInfo();
            generalInfo[0] .KeyName="updateReadOnly";
            generalInfo[0] .KeyValue="yes"; // Allow update of the read-only properties of the Lead Object.


            generalInfo[1] = new GeneralInfo();
            generalInfo[1] .KeyName="IgnoreMandatory";
            generalInfo[1] .KeyValue="no"; // 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 to create a Lead Object item
            returnStatus = SISService.CreateInstance(objectData, generalInfo, out operationInfo);

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