How to use it?

Jul 19, 2012 at 11:23 AM

Can someone explain me how to integrate and use it?

Coordinator
Jul 20, 2012 at 10:30 AM
Edited Jul 20, 2012 at 10:30 AM

Hey There.

Say you opened an account with a primary contact. And want to create a new email for some reason. This is the logic to get account id, contact id, etc

You do need to be more specific about what you are asking though. If you are new to crm 2011 development. I think SDK is your best friend to speed things up.

Jaimie

var currentUserId = Xrm.Page.context.getUserId();
var accountId = Xrm.Page.data.entity.getId();
var primarycontact = Xrm.Page.getAttribute("primarycontactid").getValue();

var contactId = null;
if(primarycontact != null) 
{
    contactId = Xrm.Page.getAttribute("primarycontactid")[0].id;
}

var createEmail = new XrmServiceToolkit.Soap.BusinessEntity("email");
createEmail.attributes["subject"] = "Test Email subject";
createEmail.attributes["description"] = "This email was created by the XrmServiceToolkit.Soap.Create() sample.";

var from = [
   { id: whoamiUserId, logicalName: "systemuser", type: "EntityReference" }
];

createEmail.attributes["from"] = { value: from, type: "EntityCollection" };

var to = [
   { id: accountId, logicalName: "account", type: "EntityReference" },
   { id: contactId, logicalName: "contact", type: "EntityReference" }
];

createEmail.attributes["to"] = { value: to, type: "EntityCollection" };

var cc = [
   { id: accountId, logicalName: "account", type: "EntityReference" },
   { id: contactId, logicalName: "contact", type: "EntityReference" }
];

createEmail.attributes["cc"] = { value: cc, type: "EntityCollection" };

var bcc = [
   { id: accountId, logicalName: "account", type: "EntityReference" },
   { id: contactId, logicalName: "contact", type: "EntityReference" }
];

createEmail.attributes["bcc"] = { value: bcc, type: "EntityCollection" };

createEmail.attributes["directioncode"] = true;

var emailId = XrmServiceToolkit.Soap.Create(createEmail);

Sep 12, 2013 at 4:20 PM
Hi,

This is what I did to create a custom activity... setting the regardingobjectid
var regarding = [
    { id: Xrm.Page.data.entity.getId(), logicalName: entitylogicalname, type: "EntityReference" }
];

var trigger = new XrmServiceToolkit.Soap.BusinessEntity("cht_plugintrigger");
trigger.attributes["subject"] = subject;
trigger.attributes["regardingobjectid"] = 
         { id: regardingobjectid, logicalName: entitylogicalname, type: "EntityReference" };

triggerId = XrmServiceToolkit.Soap.Create(trigger);