CampusNexus CRM iServices Help
CreateObject Method |
Sample Code for creating a custom Shared Object using the CreateObject method of CampusNexus CRM COF iService.
In the following sample code we will be creating an item of the Sales Executive Object, a custom Shared Object in CampusNexus CRM, with the following Properties details:
-
Name - Mark Phillips
-
Owner - Agatha
-
E-mail – Mark@WorldWaves.com
-
Phone – 566-523-5451
-
Teams to which Mark Phillips belong to - Georgia and Virginia.
Sample Code for the CreateObject Method
public void CreateSalesExecutiveCofiService() { //Creating an Instance of the COF iService COFWebService CofService = new COFWebService(); //Generating the UsernameToken Information UsernameToken userToken = getUserToken("ParkerRoy", "password"); //Associating the Username Token Information with the COF iService instance CofService.RequestSoapContext.Security.Tokens.Add(userToken); CofService.RequireMtom = false; long objectType = 5007; //Object Type of Sales Executive Object string objectName = "Mark Philip"; // Name of Sales Executive Instance long ownerID = 1155; // User ID of Agatha long teamID = -1; // Not applicable for Shared Object string addTeams = "53,54"; //Team IDs for Georgia, Virginia to which the Sales Executive Mark Phillip belongs. //Initializing the PropertyInfo class with required Information PropertyInfo[] propertyData = new PropertyInfo[3]; // 3 properties are passed for creation of the Sales Executive Object item. //Setting the values of the PropertyInfo class for the Name Property of the Sales Executive Object PropertyInfo propName = new PropertyInfo(); propName.propertyID = 21807; //ID of the Name Property of the Sales Executive Object. propName.propValue = "Mark Philip"; //Value of the Name Property of the Sales Executive Object. propertyData[0] = propName; //Setting the values of the PropertyInfo class for the Phone Property of the Sales Executive Object PropertyInfo propPhone = new PropertyInfo(); propPhone.propertyID = 21842; //ID of the Phone Property of the Sales Executive Object. propPhone.propValue = "566-523-5451"; //Value of the Phone Property of the Sales Executive Object. propertyData[1] = propPhone; //Setting the values of the PropertyInfo class for the E-mail Property of the Sales Executive Object PropertyInfo propEmail = new PropertyInfo(); propEmail.propertyID = 21840; //ID of the E-mail Property of the Sales Executive Object propEmail.propValue = "mark@worldwaves.com"; //Value of the E-mail Property of the Sales Executive Object propertyData[2] = propEmail; long InstanceID = -1; // Passing the instance ID as -1 as we are creating a new Object item. long result = 0; //Setting the return value as success so that correct value is reflected when the method call completes. string error = ""; // Error description obtained on method completion. result = CofService.CreateObject(objectType, objectName, ownerID, teamID, addTeams, propertyData, out InstanceID, out error); if (result != 0) { //Handle Error } }