Wednesday, April 1, 2015

Fetch Xml to Get Workflow Id by Name

 <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>  
  <entity name='workflow'>  
   <attribute name='workflowid' />  
   <attribute name='name' />  
   <attribute name='category' />  
   <attribute name='primaryentity' />  
   <attribute name='statecode' />  
   <attribute name='createdon' />  
   <attribute name='ownerid' />  
   <attribute name='owningbusinessunit' />  
   <attribute name='type' />  
   <order attribute='name' descending='false' />  
   <filter type='and'>  
    <condition attribute='type' operator='eq' value='1' />  
    <filter type='or'>  
     <condition attribute='category' operator='eq' value='0' />  
     <filter type='and'>  
      <condition attribute='category' operator='eq' value='1' />  
      <condition attribute='languagecode' operator='eq-userlanguage' />  
     </filter>  
    </filter>  
    <condition attribute='name' operator='eq' value='WORKFLOW NAME' />  
   </filter>  
  </entity>  
 </fetch>  

Thursday, March 5, 2015

New Line in SSRS Text box

=Fields!AddressLine1 + VBCRLF + Fields!AddressLine2 + VBCRLF + Fields!AddressLine3 

OP:
 Address1
 Address2
 Address3


Note: If VBCRLF is used first or last part the expression, it has no impact on result. If you want a line in the first or last, then use one more extra VBCRLF.

Thursday, February 26, 2015

Switch HTTP request object for browser compatability

 function GetRequestObject() {  
   if (window.XMLHttpRequest) {  
     return new window.XMLHttpRequest;  
   } else {  
     try {  
       return new ActiveXObject("MSXML2.XMLHTTP.3.0");  
     }  
     catch (ex) {  
       return null;  
     }  
   }  
 }  

Monday, August 25, 2014

Set Option Set by OptionSet Text

function SetValue(optionsetAttribute, optionText)
{
 var options = Xrm.Page.getAttribute(optionsetAttribute).getOptions();
 for(i = 0; i < options.length; i++)
 {
  if (options[i].text == optionText)
   Xrm.Page.getAttribute(optionsetAttribute).setValue(options[i].value);
 }
}
Calling of the function
SetValue("new_country", "India")

Thursday, July 3, 2014

Using ExecuteMultipleRequest to do bulk operations

Today i came across a nice feature provided in SDK which allows me to do bulk operations in a single call to the server.

For example if i have to create 1000 records within a plugin

The only way was to loop the collection of records and use Service.Create(entity);
This will create 1000 calls to the CRM and is time consuming.

Using ExecuteMultipleRequest you can perform this operation by only sending 1 request to the CRM.
Let see how this can be accomplished

Note: ExecuteMultipleRequest is available in CRM sdk update rollup 12 onwards

In the below example i am deleting 1000 records

 

  
ExecuteMultipleRequest BulkDeleteRequest = new ExecuteMultipleRequest()
                {
                    // Assign settings that define execution behavior: continue on error, return responses. 
                    Settings = new ExecuteMultipleSettings()
                    {
                        ContinueOnError = false,
                        ReturnResponses = true
                    },
                    // Create an empty organization request collection.
                    Requests = new OrganizationRequestCollection()
                };
 foreach (var item in recordstoDelete.Entities)
                {
                    DeleteRequest delRequest = new DeleteRequest() { Target = new EntityReference(item.LogicalName, item.Id) };
                    BulkDeleteRequest.Requests.Add(delRequest);
                }
                ExecuteMultipleResponse BulkDeleteResponse = (ExecuteMultipleResponse)service.Execute(BulkDeleteRequest);




Run-time limitations

  1. Maximum batch size –1000
  2. Throttling of concurrent calls – for Microsoft Dynamics CRM Online there is a limit of 2 concurrent ExecuteMultipleRequest executions per organization
In one of the blog post from Sonoma partner they claim that the performance is increased by 600%
Here is the link 
http://blog.sonomapartners.com/2013/01/executemultiplerequest-performance.html

Sunday, May 18, 2014

Microsoft Dynamics CRM 2013 Marketing Automation

Recently i got a chance to review the book on "Microsoft Dynamics CRM 2013 Marketing Automation".
This book covers the Marketing aspects and the capabilities of Dynamics CRM 2013 and Briefly covers ‪‎coremotives‬ and ‪clickdimensions‬. Click on the link to know more details about the book http://goo.gl/2Ze97E

Thursday, March 20, 2014

Set Unresolved Email Id's in party List from Java Script

function setUnresolvedRecipient() {
    var unresolvedemail = "test@testing.com"

    if (unresolvedValue != null) {
        var obj = new Object(); //create the unresolved object
        obj.name = unresolvedemail;
        obj.category = 3;
        obj.data = unresolvedemail;
        obj.type = "9206";

        var toField = Xrm.Page.getAttribute("to");
        var toValue = toField.getValue();
        if (toValue != null) {
            toValue.push(obj); //if there are already other values, add to it
            toField.setValue(toValue);
        }
        else {
            toField.setValue([obj]); //if 'to' field is null, just override it
        }
        unresolvedField.setValue(null); //wipe the field after adding it to the 'to' list
    }
}

This will set the email "test@testing.com" in the To party list on the Email Activity