Wednesday, May 20, 2015

Our Clients doesn't like this

Hi,

Most of the customers doesn't like to see the loading(Spinner) symbol in CRM.

Sometimes, we develop some custom portals where the look and feel of it would be the same as CRM. We can show the same spinner that was used in CRM.

Here is the Spinner for you..



Run spinner run :)

Hope this helps.

--
Happy CRM'ing
Gopinath. 

Get OptionSetValue Label using RetrieveAttributeRequest and PicklistAttributeMetadata

Hi,

Sometimes, we get the requirement where we need to get the OptionSetValue label in the plugin/workflow/some program.
We can get that label by using RetrieveAttributeRequest and PicklistAttributeMetadata.

Here is the C# code for it.

private string GetCRMOptionSetValueLabel(IOrganizationService objService, string strEntityName, string strOptionSetName, int intOptionSetValue)
{
            RetrieveAttributeRequest reqOptionSet = new RetrieveAttributeRequest();
            reqOptionSet.EntityLogicalName = strEntityName;
            reqOptionSet.LogicalName = strOptionSetName;
            RetrieveAttributeResponse resp = (RetrieveAttributeResponse)objService.Execute(reqOptionSet);
            PicklistAttributeMetadata opdata = (PicklistAttributeMetadata)resp.AttributeMetadata;
            var option = opdata.OptionSet.Options.FirstOrDefault(o => o.Value == intOptionSetValue);
            return option.Label.LocalizedLabels.FirstOrDefault().Label;
}

Hope this helps.

--
Happy CRM'ing
Gopinath

InitializeFromRequest in CRM

Hi,

When I was working some relationships and mappings, we got a requirement to create a child record in the plugin.

From UI, we have mapped the fields and the same fields we need to use for creating the record in the plugin. After some search I came to know that there is a SDK method available for this from CRM 4.0. i.e InitializeFromRequest

Let's have a look at it now.

I have some fields in the Account entity which I would like to map to Child entity (Student in my case). Here is the mappings for this.

Account Form

Student Form
Mappings


Now tried creating student record form CRM UI. It automatically populated the mapped fields.



Let us see how can we achieve the same thing using SDK message.

Here is the C# code I have written for it


// Create the request object
InitializeFromRequest initializeFromRequest = new InitializeFromRequest();
// Set the properties of the request object
initializeFromRequest.TargetEntityName = "new_students";
// Create the EntityMoniker
initializeFromRequest.EntityMoniker = new EntityReference("account", new Guid("43A0F1C2-7CF5-E411-80D5-C4346BAC59E8"));
// fields to initialised from parent entity
initializeFromRequest.TargetFieldType = TargetFieldType.All;
// Execute the request
InitializeFromResponse initializeFromResponse = (InitializeFromResponse)objService.Execute(initializeFromRequest);
Entity entStudent = null;
if (initializeFromResponse.Entity != null)
{
     //get entity from the response
     entStudent = initializeFromResponse.Entity;
     // set the name for the Student entity
     entStudent.Attributes.Add("new_name", "Test");
     //create a new Student record
    objService.Create(entStudent);
}
After I debug it this is what it gave. I just used the same and created a record



Points to be noted
  1. It can be used where we can 1:N relationships
  2. The request does not create a new record but the response can be used to create a new record.

Hope this helps.

--
Happy CRM'ing
Gopinath

Monday, May 18, 2015

Set the CRM Form as Read Only(Disabled) in MS CRM 2011/2013/2015

Hi,

Sometimes we get requirement to disable each and every field on the CRM form based on a condition.

We can achieve that functionality by writing simple JavaScript.

function setFormAsReadOnly() {
    //Write you conditions here.
    disableFormFields(true);
}

function doesControlHaveAttribute(control) {
    var controlType = control.getControlType();
    return controlType != "iframe" && controlType != "webresource" && controlType != "subgrid";
}

function disableFormFields(onOff) {
    Xrm.Page.ui.controls.forEach(function (control, index) {
        if (doesControlHaveAttribute(control)) {
            control.setDisabled(onOff);
        }
    });
}
Hope this helps.

--
Happy CRM'ing
Gopinath.

Special Characters in Fetch XML

Hi,

We all know that Fetch XML is the wonderful and great feature given in CRM. 
Today, I got an error while working on retrieving some records from CRM. The issue was caused by the special characters.

Here is the my C# code in which I am retrieving account information by passing name.

public static Entity GetAccountInformation1(IOrganizationService objService)
{
     Entity entAccount = null;
     string strAccountName = "johnson & johnson";
     string strFetchXML = @"<fetch version='1.0' output-format='xml-platform'  mapping='logical' distinct='false'>
                            <entity name='account'>
                            <attribute name='name' />
                            <attribute name='primarycontactid' />
                            <attribute name='telephone1' />
                            <attribute name='accountid' />
                            <order attribute='name' descending='false' />
                            <filter type='and'>
                                <condition attribute='name' operator='eq' value='" + strAccountName + "'/>" +
                             @"</filter>
                             </entity>
                             </fetch>";
      EntityCollection entCollection = objService.RetrieveMultiple(new FetchExpression(strFetchXML));
      if (entCollection != null && entCollection.Entities.Count > 0)
      {
            entAccount = entCollection.Entities[0];
      }
      return entAccount;
}

And after I execute, got the below exception.

Don't worry, this is very simple to solve. Just use HTMLEncode before passing the dynamic values.
Here is the thing what I have changed for making the code to work.


Hope it helps.

--
Happy CRM'ing
Gopinath.

 

Get and Set Look Up Details in CRM 2011/2013/2015.

Hi,

Here is the JavaScript for getting/setting Look Up details in CRM 2011/2013/2015.


// Get Look Up Details.
function getLookUp() {
    var varEntityName, varEntityId, varEntityType, varLookupFieldObject;
    var varLookupFieldObject = Xrm.Page.data.entity.attributes.get("parentaccountid");
    // Get Parent Account Details.
    if (varLookupFieldObject.getValue() != null) {
        varEntityId = varLookupFieldObject.getValue()[0].id;
        varEntityType = varLookupFieldObject.getValue()[0].entityType;
        varEntityName = varLookupFieldObject.getValue()[0].name;
        setLookUpValue(varEntityId, varEntityName, varEntityType)
    }
}

// Set the Look Up.
function setLookUpValue(accountId, accountName, entityLogicalName) {
    Xrm.Page.getAttribute("new_populateparentaccount").setValue([{
        id: accountId,
        name: accountName,
        entityType: entityLogicalName
    }]);
}



Hope this helps.

--
Happy CRM'ing
Gopinath.

Get the Active Stage of the form in CRM 2013/2015

Hi,

Here is the code to get the active stage of the record in CRM 2013/2015.


var stageName = Xrm.Page.data.process.getActiveStage().getName();

Hope this helps.

--
Happy CRM'ing
Gopinath.

Retrieve Entity Information from CRM 2011 Roll Up 12.

Hi,

Now we can retrieve entity information using a SDK method. i.e.. RetrieveEntityRequest

Here is the sample code of it.

RetrieveEntityRequest retrieveRequest = new RetrieveEntityRequest
{
      EntityFilters = EntityFilters.Entity,
      LogicalName = "entityname"
};
RetrieveEntityResponse retrieveEntityResponse = (RetrieveEntityResponse)objService.Execute(retrieveRequest);

EntityFilters is a enum. Here are the values of it.

Enum Description
All Use this to retrieve all data for an entity. Value = 15.
Attributes Use this to retrieve entity information plus attributes for the entity. Value = 2.
Default Use this to retrieve only entity information. Equivalent to EntityFilters.Entity. Value = 1.
Entity Use this to retrieve only entity information. Equivalent to EntityFilters.Default. Value = 1.
Privileges Use this to retrieve entity information plus privileges for the entity. Value = 4.
Relationships Use this to retrieve entity information plus entity relationships for the entity. Value = 8.

Hope this helps.

--
Happy CRM'ing
Gopinath.
 

Friday, May 15, 2015

Welcome Screen in CRM 2015

Hi

My last was on how to disable Welcome screen in CRM 2013 on premise. Unfortunately, we don't have any option to disable that in CRM 2013 online but in CRM 2015 we have an option in the settings.


  1. Go to Settings > Administration.
  2. Choose the System Settings > General tab.
  3. Set whether users see navigation tour, set the Display navigation tour to users when they sign in to No, as shown below.
Hope this helps.
--
Happy CRM'ing
Gopinath.

Thursday, May 14, 2015

Disable CRM 2013 Welcome Screen

Hi,

Recently when I was working with one of the customers who is using CRM 2013 complained that they were getting the Welcome Screen even thought they have selected "Don't ask me again" check box.


Here is the solution for it

  1. Logon to CRM App Server and run "Regedit.exe" as an administrator.
  2. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRMAdd  and right click to new 32 Bit DWord.
  3. Name the new Dword: DisableNavTour
  4. Set the Data Value to 1
  5. Reset your IIS.
Hope this helps

--
Happy CRM'ing
Gopinath.

Plugin and RealTime Workflow, which executes first.

Hi,

Today when I was working with Real-time workflows, got a doubt that which will be executed first where a plugin and workflow are registered on the same event.

Went ahead and came to know that Plugins are executed first and then the workflows.

Here is what I did for knowing this.

Created a Single line of text field on the Account entity.
  1. Created a plugin and registered it on the Post Create event of Account and written code to update it with "Plugin" text.
  2. Created a RealTime workflow and added a step to update the new field with "RealTimeWorkflow".
  3. Created a .csv file which has some accounts and imported it to CRM.
  4. Opened Advanced Find and checked the details. Found that the field is updated with RealTimeWorkflow value which confirms that workflow is the one that is executed after the plugin.
 
Hope this helps.

--
Happy CRM'ing
Gopinath.

Set Default Landing Page in CRM

Hi,

Now we can set your default start page in CRM 2013 and next.

  1. Click on the Gear Symbol next to user detail, click on Options (to set Personal Options).
  2. Set the Default Pane and Default Tab to the required one.
Hope this helps

--
Happy CRM'ing
Gopinath.

Wednesday, May 13, 2015

Privileges that can be set at “User or None” Level only

Hi,

Today when I was working some security roles found that there are some roles which can be set either User or None level even for System Administrators.

Don't trust, open your CRM and check.


Hope this helps

--
Happy CRM'img
Gopinath.

Migrating from CRM Online to OnPremise

Hi,

Here is the procedure for migrating Online to On Premise CRM.

To request a backup of your Microsoft Dynamics CRM Online database contact Technical Support for Microsoft Dynamics CRM Online. For contact information, see Contact Technical Support.


The backup of your Microsoft Dynamics CRM Online SQL database must be restored by using a server running the same (or a newer) version of Microsoft SQL Server as the database you receive.  You will be able to request the version you need before receiving the database.

Restore the copy of the Microsoft Dynamics CRM Online SQL database to a computer running SQL Server in the target Microsoft Dynamics CRM on-premises deployment. To do this, follow these steps:

a.      Open Microsoft SQL Server Management Studio, and then connect to the appropriate instance of Microsoft SQL Server.

b.      In Object Explorer, right-click Databases, and then click Restore Database.

c.      Type the name of a new database in the To database open text box.  The database name must include _MSCRM in the name. For example the database name is PoC_MSCRM.

d.      On the General page, in the Source for restore section, click From device.

e.      Click the browse button in the From device option. This opens the Specify Backup window.

f.       In the Specify Backup window, click the Add button to open the Locate Backup File window.

g.      Select the file you want to use for the restore operation, and then click OK.

h.      Click OK to close the Specify Backup window.

i.       Mark the checkbox in the Restore column next to the backup set option.

j.       Click OK to begin the restore process.

Click here for more information

Hope this helps

--
Happy CRM'img
Gopinath.

Copy Workflows in Dyanmics CRM 2011/2013/2015

Hi,

Sometimes, we might have a very big and complex workflow that you want to copy and re-use it for another requirement. You don't have redo all the thing now, just follow the below steps

  1. Change the workflow to a process template and activate the workflow.
  2. Create a new workflow and select type as New Process from existing Template
  3. Select the process template which you would like to copy.
  4. Do the changes and activate it.
  5. Now, go back change the original workflow to Activate as Process and activate it.
Hope this helps.

--
Happy CRM'img
Gopinath 

Tooltips in MS CRM 2013

Hi,

We can define tooltips from CRM 2013 onwards and that will be shown when hovering the mouse over a field.


So guys its time for clearing junk data if you are upgrading. You may need to revisit the descriptions.

Hope this helps.

--
Happy CRM'ing
Gopinath

Add an Image to Custom Entity

Hi All,

We can add an image to custom entity in CRM. Just follow below steps, it's very simple.
  1. Open the solution that has custom entity
  2. Select Custom entity and create a new field
  3. Enter a display name and then select the type as Image
  4. Click on the name of the entity
  5. You will now see that the Primary image field is populated with your new image field

  6. Navigate to the forms of the custom entity
  7. Open up the form
  8. Click on Form Properties
  9. Click on Display tab and tick the “Show image in the form”


  10. Save and Publish
  11. You will now add an image to a custom entity
Hope this helps.
--
Happy CRM'img
Gopinath. 

Export and Import Themes - MS CRM 2015 Update 1

Hi all,

The amazing thing that was introduced in CRM Update 1 is Themes.

But I see that we cannot add Themes to the solution, so immediately our million dollar question how can we move themes from one organization to other.

Don't worry, you can still move it from one organization to another by using the standard export/import



Hope this helps
--
Happy CRM'img
Gopinath

Tuesday, May 12, 2015

OpenQuickCreate - MS CRM 2015 Update 1

Here is one more new feature which was introduced in CRM 2015 Update 1. i.e openQuickCreate

Now, we can open quick create forms using JavaScript and also the wonderful thing here is You can use this function to set default values using attribute mappings or for specific attributes. If the user saves the record, you can capture a reference to the record created.

For testing purpose, I have created a pick list and written the below code on the change of pick list.

Syntax
Xrm.Utility.openQuickCreate(entityLogicalName,createFromEntity,parameters).then(successCallback, errorCallback);

Here is the JavaScript code

function CreateQuickCreateContact() {
    var account = { entityType: "account", id: Xrm.Page.data.entity.getId() };
    var callback = function (lookup) {
        console.log("Created new account with name" + lookup.savedEntityReference.name + " and id:" + lookup.savedEntityReference.id);
    }
    var errorCallback = function (lookup) {
        console.log("Error");
    }
    var setName = { name: "Child account of " + Xrm.Page.getAttribute("name").getValue() };
    Xrm.Utility.openQuickCreate("account", account, setName).then(callback, errorCallback);
}


I have added this code to trigger on the change of pick list.

On change of the field


If you observe, it opened the quick create form with the name parameter which is passed from java script.


 After the save, a callback function is called.


  
 --
Happy CRM'img
Gopinath