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

Tuesday, February 4, 2014

Mapping custom fields on the Opportunity product entity to the Quote product in Microsoft Dynamics CRM 2011


Click Below:
Mapping custom fields on the Opportunity product entity to the Quote product in Microsoft Dynamics CRM 2011:


For Online Navigate to

https://OrgName.crm4.dynamics.com/XRMServices/2011/OrganizationData.svc/EntityMapSet
and search for the entity map record and replace the entitymapid

http://mycrmserver/Tools/SystemCustomization/Relationships/Mappings/mappingList.aspx?mappingId=yourGUIDhere