CampusNexus CRM iServices Help
CreateInteraction Method |
Sample Code for creating an Interaction using the CreateInteraction method of CampusNexus CRM Interaction iService.
In the following sample code, we will be creating an Interaction based on an e-mail with attachment that is received from a Contact, John Peter. This Interaction is assigned to CampusNexus CRM User, Agatha. Following details are used in this sample code to create an Interaction:
-
Contact ID of John Peter - 120.
-
User ID of Agatha in CampusNexus CRM - 1155.
-
Team to which the new Interaction must be assigned to is Admission that has the ID as 53.
Sample Code for the CreateInteraction Method
public void CreateInteractionSample() { //Creating an Instance of the Interaction Service InteractionWebService interactionService = new InteractionWebService(); //Generating the Username Token UsernameToken userToken = getUserToken("ParkerRoy", "password"); //Associating the Username Token with the Interaction iService Instance interactionService.RequestSoapContext.Security.Tokens.Add(userToken); interactionService.RequireMtom = false; long contactID = 120; //ID of the Contact for which Interaction has to be created string phone = "";// Not passing this value in this sample as the medium of the Interaction is not phone. DateTime receivedAt = DateTime.Now; // Time when message was received int receivedByUserID = 0; // Indicates that the Interactionn is created by int mediaID=5; // 5 is the ID for the E-mail medium. int direction=1; // 1 indicates it is an Incoming message. string subject="Applying for Visual Arts Course"; int teamID=53; // ID of the Admissions Team in which the Interaction must be created. int assignedToUserId=1155; // ID of the User to whom the Interaction must be assigned. int aliasId=1; //ID of the e-mail alias used in the Interaction. int priority=1; //1 indicates that the priortiy of the Interaction is Normal. int resolved=0;//0 indicates that the Interaction state is Open. //Message content received from the Contact string ContactMsg= @"<!DOCTYPE html> <html> <body> Hi, <p>I want to apply for the Visual Arts course in your university. Could you please provide more details on the course? I have attached my profile for your perusal.</p> <br> <p>Thanks,</p> <br> <p>John Peter</p> </body> </html>"; string userMsg=""; //Specifying this parameter as blank. //Initializing the InteractionAttachmentData class with required Information InteractionAttachmentData[] intAttach = new InteractionAttachmentData[1]; intAttach[0]= new InteractionAttachmentData(); intAttach[0].fileBlob = System.IO.File.ReadAllBytes(@"D:/Upload/MyProfile.pdf"); //Path from where the attachment is uploaded. intAttach[0].fileName = "MyProfile"; intAttach[0].isNewAttachment = true; intAttach[0].cId = ""; //Setting the values of the Language Property for the Interaction PropertyInfo[] propData = new PropertyInfo[1]; propData[0] = new PropertyInfo(); propData[0].propertyID=1000002; // ID of the Language Property propData[0].propValue="1033"; // Indicates the language is English(United States) bool updateReadOnly=true; // Read-only Properties will be updated. bool ignoreMandatory=true; // Unfilled Mandatory Properties check will be ignored. long interactionID=-1; long eventID=-1; string error=""; bool contactPreviousBlocked=false; long result = 0; //Calling the CreateInteraction method result= interactionService.CreateInteraction(contactID, phone, receivedAt, receivedByUserID, mediaID, direction, subject, teamID, assignedToUserId, aliasId, priority, resolved, ContactMsg, userMsg, intAttach, propData, updateReadOnly, ignoreMandatory, out interactionID, out eventID, out error, out contactPreviousBlocked); if (result != 0) { } }