We have a Microsoft Dynamics CRM 2015 On premise. Recently the business rule for Entity A has change, and now only Sys Admin and Security Role A can assign those records from Entity A.
In order to achieve this task a javascript function has been created:
function ifCondition() {
try
{
if (UserHasRoles('System Role A') == true)
{return true;}
else if (UserHasRoles('System') == true)
{return true;}
else
{return false;}
}
catch (err) {
return false;
}
} // End Function ifCondition
in the entity form we have another JS with reference the above function:
if (ifCondition())
{EnableField("ownerid");}
else {DisableField("ownerid");}
This part works like a charm.
in the ribbonDiffxml we created
this enabledrule
<EnableRule Id="Custom.new_entityA.NameofEnabledRule.EnableRule">
<CustomRule FunctionName="DisableField" Library="$webresource:new_/shared/scripts/Javascriptfilewithfunction.js" />
</EnableRule>
and on the Command definition we have these Enabled and Display Rules:
<CommandDefinition Id="Mscrm.AssignPrimaryRecord">
<EnableRules>
<EnableRule Id="Mscrm.FormStateNotNew" />
<EnableRule Id="Mscrm.AssignPrimaryPermission" />
<EnableRule Id="Mscrm.NotOffline" />
<EnableRule Id="Custom.new_entityA.NameofEnabledRule.EnableRule" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Mscrm.AssignPrimaryPermission" />
<DisplayRule Id="Mscrm.NotClosedActivity" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="Mscrm.CommandBarActions.assignObject" Library="/_static/_common/scripts/CommandBarActions.js">
<CrmParameter Value="PrimaryEntityTypeCode" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
<CommandDefinition Id="Mscrm.AssignSelectedRecord">
<EnableRules>
<EnableRule Id="Mscrm.SelectionCountAtLeastOne" />
<EnableRule Id="Mscrm.VisualizationPaneNotMaximized" />
<EnableRule Id="Mscrm.NotOffline" />
<EnableRule Id="Mscrm.IsValidForHierarchyView" />
<EnableRule Id="Custom.new_entityA.NameofEnabledRule.EnableRule" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Mscrm.AssignSelectedEntityPermission" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="Mscrm.GridCommandActions.assignSelectedRecords" Library="/_static/_common/scripts/CommandBarActions.js">
<CrmParameter Value="SelectedControl" />
<CrmParameter Value="SelectedControlSelectedItemReferences" />
<CrmParameter Value="SelectedEntityTypeCode" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
Now, the problem. Sys admin can see and assign the records perfectly both in lower environment, in Prod, and a Prod like environment with a copy of Production
Users which have System Role A when this change was introduce, CANNOT assign in Prod using the Assign button, but can in lower environments and in the Prod like environment. By the way the CAN ASSIGN the record by change the ownerid field (as it is unlock for them) in all of the environments.
Admin users setup to matchs Users of the same business unit as System Role A users with System Role A security role CAN assign in all environments.
So my problem is those initial users (stakeholders) which need to Assign using the Assign button can not... what can it be? any given idea?
*This post is locked for comments