{Dynamics CRM Social Pane} Hide Posts From Social Pane in CRM 2013

In CRM 2013 Microsoft introduced the Social Pane, also known as Record Wall. Recently in our project we had a requirement to disable posts for a particular security role. To do that the first thing we did is to remove the Post Privileges for the security role. Please refer to the screenshot below.

screen 12

As you can see, remove all the privileges for the POST entity from the security role.

However after this change is made, when the user logs into the application, this is how it looks to the user.

screen 13

However what we needed to do is to hide the Posts tab altogether for this security role. A little bit of searching and found the below link. This gave us exactly what we needed.

https://community.dynamics.com/crm/b/crmsoftwareblog/archive/2013/10/26/hide-post-tab-in-social-pane-microsoft-crm-2013.aspx

All you need to do is call the method HidePosts() as mentioned in the link in the onload of the form and check for the currently logged in users security roles. And then hide the  post tab if the security role matches the condition.

Hope this helps!

{Dynamics CRM Business Process Flow} Prevent user from moving to previous stage in CRM 2013 Business Process Flows.

In CRM 2013 Business Process flow, the user can move both forward and backward to next stage and previous stage respectively using the Next/ Previous arrows. However sometimes your requirement might be to have process flows unidirectional. In that case you would not want to show the previous arrow shown to the user. Let’s see how you can achieve this using  jQuery.

Following is a business process flow that we have set up for the opportunity entity.

Screen 10

As you can see, we have both the Previous and the Next Stage buttons here.

Let’s how we can hide the previous stage button

In google chrome, using developer tools, we can explore the HTML for the Previous Stage arrow. Following is the HTML that we have.

screen 11

The Id of the Previous stage arrow is stageBackActionContainer. All we need to do is hide this div and increase the width of the “Next stage” div so that it occupies the vacant space using the code below.

function hidePreviousStageButton(stageBackActionContainer, stageAdvanceActionContainer) {
$(“#stageBackActionContainer”).hide();
$(“#stageBackActionContainer”).html(“”);
$(“#stageAdvanceActionContainer”).css(“width”, “90px”);
}

All you need to do is call the hidePreviousStageButton in the onload of the form.

Hope this helps!

{Dynamics CRM} Control CRM 2013 Business Process Next Stage and Previous Stage flow using JScript.

Recently in our project we needed to restrict the business process flow from one stage to another depending on certain conditions. The problem was that OOB CRM 2013 does allow you to plugin your custom client side code when the “Next Stage” or the “Previous Stage” icons are clicked. You can obviously register Plugins and Workflows on the business process stage change but you cannot stop the change of stages using the same. Let’s see how we can achieve this.

Below is the screenshot of an example business process flow for opportunity entity. Let’s explore what CRM does here. I have opened Chrome Developer tools and trying to explore the HTML for business process flow. I have selected the ‘Next Stage’ button.

screen 9

The id of the div is “stageAdvanceActionContainer”.

So what we need to do is override the click event with our custom function and then if our condition meets we would call the OOB event handler. The code below does the same.

function  registerBusinessProcessEvents()

{

var originalNextStageHandler = $(“#stageAdvanceActionContainer”).data(“events”)[“click”][0].handler;

 

// unbind the original next event handler

$(“#stageAdvanceActionContainer”).unbind(“click”);

 

$(“#stageAdvanceActionContainer”).click(function (e) {

// perform your custom logic here. If you want to move to the next stage just call the code below.

 

$.proxy(originalNextStageHandler, $(“#stageAdvanceActionContainer”))(e);

 

}

 

}

All you need to do is call the registerBusinessProcessEvents  function during the onload of the form.

Similarly the ID for the previous click handler is “stageBackActionContainer”. And you can handle it in the same manner as above.

 

Please note that is an unsupported customization and might not work if Microsoft decides to change the id of the div elements or the rendering model in future rollups.

 

Hope this helps!

CRM 2013 Solution Import Error – An item with the same key has already been added

In CRM 2013, while importing of solution, we faced the error “An item with the same key has already been added”.

A little bit of searching and we found this very good article which describes how to resolve the error – http://nishantrana.wordpress.com/2014/04/15/an-item-with-the-same-key-has-already-been-added-error-while-importing-solution-in-crm-2013/

However as the link suggests, it was not possible for us to delete the field since we had some data where the field was populated in the target environment. Hence we had to take the alternate route.

We unzipped the customizations and looked for the field in the customizations.xml file.

For e.g. in the screen shot below, we could see the field with physical name “new_IsOpportunityCustomer”. However when we went into the customizations of the target environment the name was “new_isopportunitycustomer”. Clearly there was a difference in casing which led to the below error.

screen 8

To resolve this we changed the physical name in the customizations.xml from “new_IsOpportunityCustomer” to “new_isopportunitycustomer” and re-imported the solution and everything worked fine.

Hope this helps!

 

{Dynamics CRM} Found More than one RibbonDiff Entity Error- CRM 2013 Solution Import

In CRM 2013, while importing of solution, we faced the above in the Entity Ribbon of the Account Entity.

To resolve the same, we unzipped the customization file that we were importing and then opened the customizations.xml file in a xml editor and checked for the RibbonDiff part for the account entity.

We found duplicate entries in the HideCustomAction. See the screenshot below.

screen 7

 

We just removed the duplicate entries and the re-imported the solution and it worked again

Hope this helps!

{Dynamics CRM} Default Potential Customer lookup to show only accounts/ Contacts in CRM 2013 Business Process Flows

In the opportunity entity, we have a field “Potential Customer” which is of type “Customer” and it can be both account or contact entity. However sometimes we might need to customize the same to show only contacts or accounts.

For this in the form load of the opportunity entity, just add the two lines of code shown below.

$(“#customerid”).attr(“lookuptypes”, “1”);

$(“#customerid”).find(“img”).attr(“lookuptypes”, “1”);

However in CRM 2013 if we are using business process flows and we include the Potential Customer in the business process flow, the above line of code wouldn’t do the job for you. For that just add the two lines of code shown below.

$(“#header_process_customerid”).attr(“lookuptypes”, “1”);

$(“#header_process_customerid”).find(“img”).attr(“lookuptypes”, “1”);

 

Hope this helps!

DisableViewPicker not working in CRM 2013

In CRM we are often faced with the requirement of disabling the view picker of a lookup view.

Say we a have a lookup field called customerid on the form of another entity  and on click of the lookup, we need to disable the view selector of the lookup view window.

In Crm 2011 this could be achieved with the following code

$(“#customerid”).attr(“disableviewpicker”, “1”)

However in CRM 2013, you might find the  code above not working as expected. To do the same in CRM 2013, the trick is not find the image of the particular lookup field and  apply the code to the image tag.

$(“#customerid”).find(“img”).attr(“disableviewpicker”, “1”)

Hope this helps!