Tuesday, December 29, 2009

Update Method using Java Script

Hi,
Here is an example to update entoty request only in Client Side

// Prepare variables for updating a contact.
var contactId = "56914948-991C-DD11-AD3A-0003FF9EE217";
var newAddressLine1 = "34 Market St.";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Update xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entity xsi:type='contact'>"+
"<address1_line1>"+newAddressLine1+"</address1_line1>"+
"<contactid>"+contactId+"</contactid>"+
"</entity>"+
"</Update>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Update");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display a confirmation message and open the updated contact.
else
{
alert("Contact with id = "+contactId+" successfully updated.");
window.open("/sfa/conts/edit.aspx?id={"+contactId+"}");
}

Enjoy,
Rami Heleg

RetrieveMultiple Method Using Java Script

Hi,
Here is an example to RetrieveMultiple only in Client Side

// Prepare variables to retrieve the contacts.
var searchCity = "Sammamish";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"+
" xsi:type='q1:QueryExpression'>"+
"<q1:EntityName>contact</q1:EntityName>"+
"<q1:ColumnSet xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>fullname</q1:Attribute>"+
"<q1:Attribute>contactid</q1:Attribute>"+
"</q1:Attributes>"+
"</q1:ColumnSet>"+
"<q1:Distinct>false</q1:Distinct>"+
"<q1:Criteria>"+
"<q1:FilterOperator>And</q1:FilterOperator>"+
"<q1:Conditions>"+
"<q1:Condition>"+
"<q1:AttributeName>address1_city</q1:AttributeName>"+
"<q1:Operator>Like</q1:Operator>"+
"<q1:Values>"+
"<q1:Value xsi:type='xsd:string'>"+searchCity+"</q1:Value>"+
"</q1:Values>"+
"</q1:Condition>"+
"</q1:Conditions>"+
"</q1:Criteria>"+
"</query>"+
"</RetrieveMultiple>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
Enjoy,
Rami Heleg

Retrieve Method Using JScript

Hi,
Here is an example to retrieve data only in Client Side

// Prepare variables for a contact to retrieve.
var contactid = "4696f8cb-9a1c-dd11-ad3a-0003ff9ee217";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>fullname</q1:Attribute>"+
"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:fullname").nodeTypedValue);
}
The following is an example of a successful response:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<RetrieveResponse xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<RetrieveResult xmlns:q1="http://schemas.microsoft.com/crm/2007/WebServices" xsi:type="q1:contact">
<q1:fullname>Jesper Aaberg</q1:fullname>
<q1:contactid>{4696F8CB-9A1C-DD11-AD3A-0003FF9EE217}</q1:contactid>
<q1:owningbusinessunit>{0EA35030-3EC9-DC11-A8D2-0003FF9EE217}</q1:owningbusinessunit>
</RetrieveResult>
</RetrieveResponse>
</soap:Body>
</soap:Envelope>

Enjoy,
Rami Heleg

Run Fetch Method using java script

Hi,
Here is an example to execute fetch only in Client Side

// Prepare variables to fetch accounts.
var fetchMapping = "logical";
var entityName = "account";
var firstColumn = "accountid";
var secondColumn = "name";
var linkEntity = "systemuser";
var linkEntityTo ="owninguser";
var filterType = "and";
var conditionAttribute = "lastname";
var operator = "ne";
var value = "Cannon";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<fetchXml><fetch mapping='"+fetchMapping+"'>"+
"<entity name='"+entityName+"'>"+
"<attribute name='"+firstColumn+"'/>"+
"<attribute name='"+secondColumn+"'/>"+
"<link-entity name='"+linkEntity+"' to='"+linkEntityTo+"'>"+
"<filter type='"+filterType+"'>"+
"<condition attribute='"+conditionAttribute+"'"+
" operator='"+operator+"' value='"+value+"'/>"+
"</filter>"+
"</link-entity>"+
"</entity>"+
"</fetch></fetchXml>"+
"</Fetch>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}

Enjoy,
Rami Heleg

Execute Method using Java Script

Hi,
Here is an example to execute request only in Client Side

// Prepare variables to add a new product to a campaign.
var CampaignId = "771ed82b-6b27-dd11-b452-0003ff9ee217";
var EntityId = "3F26C82A-A2E1-DC11-A277-001AA0B84538";
var EntityName = "product";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<Request xsi:type='AddItemCampaignRequest'>"+
"<CampaignId>"+CampaignId+"</CampaignId>"+
"<EntityId>"+EntityId+"</EntityId>"+
"<EntityName>"+EntityName+"</EntityName>"+
"</Request>"+
"</Execute>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display a confirmation message and open the campaign record.
else
{
alert("Product with id = "+EntityId+" successfully added to Campaign with id = "+CampaignId+".");
window.open("/ma/camps/edit.aspx?id={"+CampaignId+"}");
}


Enjoy,
Rami Heleg

Delete Entity in Client Side ( Java Script only)

Hi,
here is an example to delete entity only in client side:


// Identify the contact to delete.
var contactid = "57a4e111-7027-dd11-b452-0003ff9ee217";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Delete xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"</Delete>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request,
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Delete");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result,
var resultXml = xHReq.responseXML;

// Check for errors,
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display confirmation message.
else
{
alert("Contact with id = "+contactid+" successfully deleted");
}

Enjoy,
Rami Heleg

Create Entity in client side ( Java Script only)

Hi,
here is an example of create entity only in client side:

// Prepare values for the new contact.

var firstname = "Jesper";
var lastname = "Aaberg";
var donotbulkemail = "true";
var address1_stateorprovince = "MT";
var address1_postalcode = "99999";
var address1_line1 = "23 Market St.";
var address1_city = "Sammamish";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
var xml = "<?xml version'1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entity xsi:type='contact'>"+
"<address1_city>"+address1_city+"</address1_city>"+
"<address1_line1>"+address1_line1+"</address1_line1>"+
"<address1_postalcode>"+address1_postalcode+"</address1_postalcode>"+
"<address1_stateorprovince>"+address1_stateorprovince+"</address1_stateorprovince>"+
"<donotbulkemail>"+donotbulkemail+"</donotbulkemail>"+
"<firstname>"+firstname+"</firstname>"+
"<lastname>"+lastname+"</lastname>"+
"</entity>"+
"</Create>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Create");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Open new contact record if no errors.
else
{
var contactid = resultXml.selectSingleNode("//CreateResult");
window.open("/sfa/conts/edit.aspx?id={"+contactid.nodeTypedValue+"}");
}


Enjoy,
Rami Heleg

Tuesday, December 22, 2009

How to add supported JavaScript to pages.

Example how to add to pages JS supported by Microsoft:

1.
Create Folder under ISV



2.
add JavaScript code to page:



3.
add the next code into contact page:
var request = new ActiveXObject("Msxml2.XMLHTTP");
request.open("GET", "/isv/MyScripts/contact.js", false);
request.send(null);
eval(request.responseText);

For instance:



4.
open contact page and get the message.




Enjoy,
Rami Heleg

How to init Value on Server side

This example contain how to init all CRM Values:
CrmDateTime lDateTime = new CrmDateTime("2009/8/27T17:00:00");

CrmBoolean lBoolean = new CrmBoolean(true);

Picklist lList = new Picklist(1);

CrmDecimal lDec = new CrmDecimal(10.1);

CrmFloat lfloat = new CrmFloat(10.2);

CrmNumber lNumber = new CrmNumber(10);

Lookup oSys = new Lookup("systemuser", userId);

Owner owner = new Owner("systemuser", systemUserId);

Status lStatus = new Status(1);

EntityNameReference oReference = new EntityNameReference("systemuser");

Key key = new Key(userId);

CrmMoney lMoney = new CrmMoney(10.00);

Enjoy,
Rami Heleg

Thursday, December 3, 2009

Crm 4.0 Microsoft CRM Asynchronous failed and require restart

Hi
Error Message:

Exception type: CrmException
Exception message: The key specified to compute a hash value is expired, only active keys are valid. Expired Key : CrmKey(Id:c1bef2e2-efc5-de11-b538-005056a75caa, ScaleGroupId:00000000-0000-0000-0000-000000000000,
KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:10/31/2009 07:34:57, ExpiresOn:12/03/2009 07:34:57, CreatedOn:10/31/2009 07:34:57, CreatedBy:NT AUTHORITY\NETWORK SERVICE.

This problem occurs because Microsoft Dynamics CRM 4.0 uses the name of the SQL server that is in the organization table of the mscrm_config database when Microsoft Dynamics CRM 4.0 tries to connect to the SQL server. If the name is lowercase, the Async service cannot correctly process the jobs in the ScaleGroupOrganizationMaintenanceJobs table. The SqlServerName name must be the same as the value that is returned by the @@servername global variable.

Because of that the solution is to install Rollup 7.0

Microsoft Articles:

<a href="http://support.microsoft.com/kb/949844"></a>
<a href="http://support.microsoft.com/kb/949256/"></a>

Thanks and enjoy,
Rami Heleg

How to change due date filter default value for activities page:


Sometimes you need to define your default filter values for the home activities page.


Here is an example how to change due date filter default value:

Add this code to "\CRMWeb\Workplace\home_activities.aspx" page:

<script runat="server">
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
this.crmDateSelector.Selected = "Today";
this.crmGrid.Parameters.Add("scheduledend", "Today");
}
</script>

You can set these values to the crmDateSelector control:
Overdue
Today
Tomorrow
NextXDays;7
NextXDays;30
NextXDays;90
NextXMonths;6
NextXMonths;12
All

thanks,
Max Shafranski,
Team blog member.

Wednesday, December 2, 2009

List of events for each entity.

List of events for each entity.

Message Primary Entity
AddItem Campaign
AddItem CampaignActivity
AddMember List
AddMembers Team
AddProductToKit NULL
Assign Account
Assign Annotation
Assign Appointment
Assign Campaign
Assign CampaignActivity
Assign CampaignResponse
Assign Contact
Assign Contract
Assign CustomerOpportunityRole
Assign CustomerRelationship
Assign Email
Assign Fax
Assign Incident
Assign IncidentResolution
Assign Invoice
Assign Lead
Assign Letter
Assign List
Assign Opportunity
Assign OpportunityClose
Assign OrderClose
Assign PhoneCall
Assign Quote
Assign QuoteClose
Assign SalesOrder
Assign ServiceAppointment
Assign Task
Assign Template
Assign UserQuery
BackgroundSend Email
Book Appointment
Book ServiceAppointment
Cancel Contract
Cancel SalesOrder
CheckIncoming Email
CheckPromote Email
Clone Contract
Close Incident
Close Quote
Create Account
Create ActivityMimeAttachment
Create Annotation
Create Appointment
Create BusinessUnit
Create BusinessUnitNewsArticle
Create Calendar
Create Campaign
Create CampaignActivity
Create CampaignResponse
Create Competitor
Create Contact
Create Contract
Create ContractDetail
Create ContractTemplate
Create custom entity
Create CustomerAddress
Create CustomerOpportunityRole
Create CustomerRelationship
Create Discount
Create DiscountType
Create Email
Create Equipment
Create Fax
Create Incident
Create IncidentResolution
Create Invoice
Create InvoiceDetail
Create KbArticle
Create KbArticleComment
Create KbArticleTemplate
Create Lead
Create Letter
Create List
Create Opportunity
Create OpportunityClose
Create OpportunityProduct
Create OrderClose
Create PhoneCall
Create PriceLevel
Create Product
Create ProductPriceLevel
Create Queue
Create Quote
Create QuoteClose
Create QuoteDetail
Create Role
Create SalesLiterature
Create SalesLiteratureItem
Create SalesOrder
Create SalesOrderDetail
Create Service
Create ServiceAppointment
Create Site
Create Subject
Create SystemUser
Create Task
Create Team
Create Template
Create Territory
Create TransactionCurrency
Create UoM
Create UoMSchedule
CreateUoMSchedule UoMSchedule
Delete Account
Delete ActivityMimeAttachment
Delete Annotation
Delete Appointment
Delete BusinessUnitNewsArticle
Delete Calendar
Delete Campaign
Delete CampaignActivity
Delete CampaignResponse
Delete Competitor
Delete Contact
Delete Contract
Delete ContractDetail
Delete ContractTemplate
Delete custom entity
Delete CustomerAddress
Delete CustomerOpportunityRole
Delete CustomerRelationship
Delete Discount
Delete DiscountType
Delete Email
Delete Equipment
Delete Fax
Delete Incident
Delete IncidentResolution
Delete Invoice
Delete InvoiceDetail
Delete KbArticle
Delete KbArticleComment
Delete KbArticleTemplate
Delete Lead
Delete Letter
Delete List
Delete Opportunity
Delete OpportunityClose
Delete OpportunityProduct
Delete OrderClose
Delete PhoneCall
Delete PriceLevel
Delete Product
Delete ProductPriceLevel
Delete Queue
Delete Quote
Delete QuoteClose
Delete QuoteDetail
Delete Role
Delete SalesLiterature
Delete SalesLiteratureItem
Delete SalesOrder
Delete SalesOrderDetail
Delete Service
Delete ServiceAppointment
Delete Site
Delete Subject
Delete Task
Delete Template
Delete Territory
Delete TransactionCurrency
Delete UoM
Delete UoMSchedule
Delete UserQuery
DeliverIncoming Email
DeliverPromote Email
DetachFromQueue Email
Execute NULL
ExecuteById SavedQuery
ExecuteById UserQuery
Export NULL
ExportAll NULL
ExportCompressed NULL
ExportCompressedAll NULL
GrantAccess Account
GrantAccess Annotation
GrantAccess Appointment
GrantAccess Campaign
GrantAccess CampaignActivity
GrantAccess CampaignResponse
GrantAccess Contact
GrantAccess Contract
GrantAccess CustomerOpportunityRole
GrantAccess CustomerRelationship
GrantAccess Email
GrantAccess Fax
GrantAccess Incident
GrantAccess IncidentResolution
GrantAccess Invoice
GrantAccess Lead
GrantAccess Letter
GrantAccess List
GrantAccess Opportunity
GrantAccess OpportunityClose
GrantAccess OrderClose
GrantAccess PhoneCall
GrantAccess Quote
GrantAccess QuoteClose
GrantAccess SalesOrder
GrantAccess ServiceAppointment
GrantAccess Task
GrantAccess Template
GrantAccess UserQuery
Handle Appointment
Handle CampaignActivity
Handle CampaignResponse
Handle Email
Handle Fax
Handle Incident
Handle Letter
Handle PhoneCall
Handle ServiceAppointment
Handle Task
Import NULL
ImportAll NULL
ImportCompressedAll NULL
ImportCompressedWithProgress NULL
ImportWithProgress NULL
LockInvoicePricing NULL
LockSalesOrderPricing NULL
Lose Opportunity
Merge Account
Merge Contact
Merge Lead
ModifyAccess Account
ModifyAccess Annotation
ModifyAccess Appointment
ModifyAccess Campaign
ModifyAccess CampaignActivity
ModifyAccess CampaignResponse
ModifyAccess Contact
ModifyAccess Contract
ModifyAccess CustomerOpportunityRole
ModifyAccess CustomerRelationship
ModifyAccess Email
ModifyAccess Fax
ModifyAccess Incident
ModifyAccess IncidentResolution
ModifyAccess Invoice
ModifyAccess Lead
ModifyAccess Letter
ModifyAccess List
ModifyAccess Opportunity
ModifyAccess OpportunityClose
ModifyAccess OrderClose
ModifyAccess PhoneCall
ModifyAccess Quote
ModifyAccess QuoteClose
ModifyAccess SalesOrder
ModifyAccess ServiceAppointment
ModifyAccess Task
ModifyAccess Template
ModifyAccess UserQuery
Publish NULL
PublishAll NULL
RemoveBinaryData ActivityMimeAttachment
RemoveBinaryData Annotation
RemoveBinaryData SalesLiteratureItem
RemoveItem Campaign
RemoveItem CampaignActivity
RemoveMember List
RemoveMembers Team
RemoveProductFromKit NULL
RemoveRelated Invoice
RemoveRelated Lead
RemoveRelated Lead
RemoveRelated Opportunity
RemoveRelated Opportunity
RemoveRelated Opportunity
RemoveRelated Product
RemoveRelated Product
RemoveRelated Quote
RemoveRelated SalesLiterature
RemoveRelated SalesLiterature
RemoveRelated SalesOrder
Reschedule Appointment
Reschedule ServiceAppointment
Retrieve Account
Retrieve ActivityMimeAttachment
Retrieve ActivityPointer
Retrieve Annotation
Retrieve Appointment
Retrieve BusinessUnitNewsArticle
Retrieve Calendar
Retrieve Campaign
Retrieve CampaignActivity
Retrieve CampaignResponse
Retrieve Competitor
Retrieve Contact
Retrieve Contract
Retrieve ContractDetail
Retrieve ContractTemplate
Retrieve custom entity
Retrieve CustomerAddress
Retrieve CustomerOpportunityRole
Retrieve CustomerRelationship
Retrieve Discount
Retrieve DiscountType
Retrieve Email
Retrieve Equipment
Retrieve Fax
Retrieve Incident
Retrieve IncidentResolution
Retrieve Invoice
Retrieve InvoiceDetail
Retrieve KbArticle
Retrieve KbArticleComment
Retrieve KbArticleTemplate
Retrieve Lead
Retrieve Letter
Retrieve List
Retrieve Opportunity
Retrieve OpportunityClose
Retrieve OpportunityProduct
Retrieve OrderClose
Retrieve PhoneCall
Retrieve PriceLevel
Retrieve Product
Retrieve ProductPriceLevel
Retrieve Queue
Retrieve Quote
Retrieve QuoteClose
Retrieve QuoteDetail
Retrieve SalesLiterature
Retrieve SalesLiteratureItem
Retrieve SalesOrder
Retrieve SalesOrderDetail
Retrieve SavedQuery
Retrieve Service
Retrieve ServiceAppointment
Retrieve Site
Retrieve Subject
Retrieve Task
Retrieve Team
Retrieve Template
Retrieve Territory
Retrieve UoM
Retrieve UoMSchedule
Retrieve UserQuery
RetrieveExchangeRate NULL
RetrieveMultiple Account
RetrieveMultiple ActivityMimeAttachment
RetrieveMultiple ActivityPointer
RetrieveMultiple Annotation
RetrieveMultiple Appointment
RetrieveMultiple BusinessUnitNewsArticle
RetrieveMultiple Calendar
RetrieveMultiple Campaign
RetrieveMultiple CampaignActivity
RetrieveMultiple CampaignResponse
RetrieveMultiple Competitor
RetrieveMultiple Contact
RetrieveMultiple Contract
RetrieveMultiple ContractDetail
RetrieveMultiple ContractTemplate
RetrieveMultiple custom entity
RetrieveMultiple CustomerAddress
RetrieveMultiple CustomerOpportunityRole
RetrieveMultiple CustomerRelationship
RetrieveMultiple Discount
RetrieveMultiple DiscountType
RetrieveMultiple Email
RetrieveMultiple Equipment
RetrieveMultiple Fax
RetrieveMultiple Incident
RetrieveMultiple IncidentResolution
RetrieveMultiple Invoice
RetrieveMultiple InvoiceDetail
RetrieveMultiple KbArticle
RetrieveMultiple KbArticleComment
RetrieveMultiple KbArticleTemplate
RetrieveMultiple Lead
RetrieveMultiple Letter
RetrieveMultiple List
RetrieveMultiple Opportunity
RetrieveMultiple OpportunityClose
RetrieveMultiple OpportunityProduct
RetrieveMultiple OrderClose
RetrieveMultiple PhoneCall
RetrieveMultiple PriceLevel
RetrieveMultiple Product
RetrieveMultiple ProductPriceLevel
RetrieveMultiple Queue
RetrieveMultiple Quote
RetrieveMultiple QuoteClose
RetrieveMultiple QuoteDetail
RetrieveMultiple SalesLiterature
RetrieveMultiple SalesLiteratureItem
RetrieveMultiple SalesOrder
RetrieveMultiple SalesOrderDetail
RetrieveMultiple SavedQuery
RetrieveMultiple Service
RetrieveMultiple ServiceAppointment
RetrieveMultiple Site
RetrieveMultiple Subject
RetrieveMultiple Task
RetrieveMultiple Team
RetrieveMultiple Template
RetrieveMultiple Territory
RetrieveMultiple UoM
RetrieveMultiple UoMSchedule
RetrieveMultiple UserQuery
RetrievePrincipalAccess Account
RetrievePrincipalAccess Annotation
RetrievePrincipalAccess Appointment
RetrievePrincipalAccess Campaign
RetrievePrincipalAccess CampaignActivity
RetrievePrincipalAccess CampaignResponse
RetrievePrincipalAccess Contact
RetrievePrincipalAccess Contract
RetrievePrincipalAccess CustomerOpportunityRole
RetrievePrincipalAccess CustomerRelationship
RetrievePrincipalAccess Email
RetrievePrincipalAccess Fax
RetrievePrincipalAccess Incident
RetrievePrincipalAccess IncidentResolution
RetrievePrincipalAccess Invoice
RetrievePrincipalAccess Lead
RetrievePrincipalAccess Letter
RetrievePrincipalAccess List
RetrievePrincipalAccess Opportunity
RetrievePrincipalAccess OpportunityClose
RetrievePrincipalAccess OrderClose
RetrievePrincipalAccess PhoneCall
RetrievePrincipalAccess Quote
RetrievePrincipalAccess QuoteClose
RetrievePrincipalAccess SalesOrder
RetrievePrincipalAccess ServiceAppointment
RetrievePrincipalAccess Task
RetrievePrincipalAccess Template
RetrievePrincipalAccess UserQuery
RetrieveSharedPrincipalsAndAccess Account
RetrieveSharedPrincipalsAndAccess Annotation
RetrieveSharedPrincipalsAndAccess Appointment
RetrieveSharedPrincipalsAndAccess Campaign
RetrieveSharedPrincipalsAndAccess CampaignActivity
RetrieveSharedPrincipalsAndAccess CampaignResponse
RetrieveSharedPrincipalsAndAccess Contact
RetrieveSharedPrincipalsAndAccess Contract
RetrieveSharedPrincipalsAndAccess CustomerOpportunityRole
RetrieveSharedPrincipalsAndAccess CustomerRelationship
RetrieveSharedPrincipalsAndAccess Email
RetrieveSharedPrincipalsAndAccess Fax
RetrieveSharedPrincipalsAndAccess Incident
RetrieveSharedPrincipalsAndAccess IncidentResolution
RetrieveSharedPrincipalsAndAccess Invoice
RetrieveSharedPrincipalsAndAccess Lead
RetrieveSharedPrincipalsAndAccess Letter
RetrieveSharedPrincipalsAndAccess List
RetrieveSharedPrincipalsAndAccess Opportunity
RetrieveSharedPrincipalsAndAccess OpportunityClose
RetrieveSharedPrincipalsAndAccess OrderClose
RetrieveSharedPrincipalsAndAccess PhoneCall
RetrieveSharedPrincipalsAndAccess Quote
RetrieveSharedPrincipalsAndAccess QuoteClose
RetrieveSharedPrincipalsAndAccess SalesOrder
RetrieveSharedPrincipalsAndAccess ServiceAppointment
RetrieveSharedPrincipalsAndAccess Task
RetrieveSharedPrincipalsAndAccess Template
RetrieveSharedPrincipalsAndAccess UserQuery
RevokeAccess Account
RevokeAccess Annotation
RevokeAccess Appointment
RevokeAccess Campaign
RevokeAccess CampaignActivity
RevokeAccess CampaignResponse
RevokeAccess Contact
RevokeAccess Contract
RevokeAccess CustomerOpportunityRole
RevokeAccess CustomerRelationship
RevokeAccess Email
RevokeAccess Fax
RevokeAccess Incident
RevokeAccess IncidentResolution
RevokeAccess Invoice
RevokeAccess Lead
RevokeAccess Letter
RevokeAccess List
RevokeAccess Opportunity
RevokeAccess OpportunityClose
RevokeAccess OrderClose
RevokeAccess PhoneCall
RevokeAccess Quote
RevokeAccess QuoteClose
RevokeAccess SalesOrder
RevokeAccess ServiceAppointment
RevokeAccess Task
RevokeAccess Template
RevokeAccess UserQuery
Route Appointment
Route CampaignActivity
Route CampaignResponse
Route Email
Route Fax
Route Incident
Route Letter
Route PhoneCall
Route ServiceAppointment
Route Task
Send Email
Send Fax
Send Template
SendFromTemplate Email
SetRelated Invoice
SetRelated Lead
SetRelated Lead
SetRelated Opportunity
SetRelated Opportunity
SetRelated Opportunity
SetRelated Product
SetRelated Product
SetRelated Quote
SetRelated SalesLiterature
SetRelated SalesLiterature
SetRelated SalesOrder
SetState Account
SetState Appointment
SetState BusinessUnit
SetState Campaign
SetState CampaignActivity
SetState CampaignResponse
SetState Contact
SetState Contract
SetState ContractDetail
SetState custom entity
SetState DiscountType
SetState Email
SetState Fax
SetState Incident
SetState IncidentResolution
SetState Invoice
SetState KbArticle
SetState Lead
SetState Letter
SetState List
SetState Opportunity
SetState OpportunityClose
SetState OrderClose
SetState PhoneCall
SetState PriceLevel
SetState Product
SetState Quote
SetState QuoteClose
SetState SalesOrder
SetState ServiceAppointment
SetState Task
SetState TransactionCurrency
SetState UserQuery
SetStateDynamicEntity Account
SetStateDynamicEntity Appointment
SetStateDynamicEntity BusinessUnit
SetStateDynamicEntity Campaign
SetStateDynamicEntity CampaignActivity
SetStateDynamicEntity CampaignResponse
SetStateDynamicEntity Contact
SetStateDynamicEntity Contract
SetStateDynamicEntity ContractDetail
SetStateDynamicEntity custom entity
SetStateDynamicEntity DiscountType
SetStateDynamicEntity Email
SetStateDynamicEntity Fax
SetStateDynamicEntity Incident
SetStateDynamicEntity IncidentResolution
SetStateDynamicEntity Invoice
SetStateDynamicEntity KbArticle
SetStateDynamicEntity Lead
SetStateDynamicEntity Letter
SetStateDynamicEntity List
SetStateDynamicEntity Opportunity
SetStateDynamicEntity OpportunityClose
SetStateDynamicEntity OrderClose
SetStateDynamicEntity PhoneCall
SetStateDynamicEntity PriceLevel
SetStateDynamicEntity Product
SetStateDynamicEntity Quote
SetStateDynamicEntity QuoteClose
SetStateDynamicEntity SalesOrder
SetStateDynamicEntity ServiceAppointment
SetStateDynamicEntity Task
SetStateDynamicEntity TransactionCurrency
SetStateDynamicEntity UserQuery
UnlockInvoicePricing NULL
UnlockSalesOrderPricing NULL
Update Account
Update ActivityMimeAttachment
Update Annotation
Update Appointment
Update BusinessUnit
Update BusinessUnitNewsArticle
Update Calendar
Update Campaign
Update CampaignActivity
Update CampaignResponse
Update Competitor
Update Contact
Update Contract
Update ContractDetail
Update ContractTemplate
Update CustomerAddress
Update CustomerOpportunityRole
Update CustomerRelationship
Update Discount
Update DiscountType
Update Email
Update Equipment
Update Fax
Update Incident
Update IncidentResolution
Update Invoice
Update InvoiceDetail
Update KbArticle
Update KbArticleComment
Update KbArticleTemplate
Update Lead
Update Letter
Update List
Update Opportunity
Update OpportunityClose
Update OpportunityProduct
Update OrderClose
Update Organization
Update PhoneCall
Update PriceLevel
Update Product
Update ProductPriceLevel
Update Queue
Update Quote
Update QuoteClose
Update QuoteDetail
Update Role
Update SalesLiterature
Update SalesLiteratureItem
Update SalesOrder
Update SalesOrderDetail
Update Service
Update ServiceAppointment
Update Site
Update Subject
Update SystemUser
Update Task
Update Team
Update Template
Update Territory
Update TransactionCurrency
Update UoM
Update UoMSchedule
Update UserQuery
UploadFromBase64Data ActivityMimeAttachment
UploadFromBase64Data Annotation
UploadFromBase64Data SalesLiteratureItem
Win Opportunity
Win Quote

Enjoy,
Rami Heleg

How to get entity instance id in CRM 4.0 plugin for each message type

This example help to get instance id for each type of event:

Massage name “Create”:

Guid instanceID = new Guid(context.OutputParameters.Properties["id"].ToString());

Massage name “Update”:

Guid instanceID = (Guid)((Microsoft.Crm.Sdk.Key)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["Target"]).Properties[context.PrimaryEntityName + "id"]).Value;

Massage name “SetState”:

Guid instanceID = new Guid(context.OutputParameters.Properties["id"].ToString());

Massage name “Assign”:

Guid instanceID = vInstanceID = (Guid)((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “Delete”:

instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “Close”:

Guid instanceID = ((Microsoft.Crm.Sdk.Lookup)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["IncidentResolution"]).Properties[context.PrimaryEntityName + "id"]).Value;

Massage name “Route”:

Guid instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;

Massage name “SetStateDynamicEntity”:

Guid instanceID = ((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["EntityMoniker"]).Id;


Enjoy,
Rami Heleg