Saturday, 30 January 2016

This bundle can't be published because it has too many properties. A bundle in your organization can't have more than 50 properties

Hi,

Today I was working with Product Configuration in CRM. We have created properties under family and the same family as parent for creating bundles. When we publish the bundle, we have received the below exception with the following message.

"This bundle can't be published because it has too many properties. A bundle in your organization can't have more than 50 properties."


This limit can be increased in System Settings.

Open System Settings --> Sales

Hope this helps.

--
Happy CRM'ing

Gopinath

Tuesday, 26 January 2016

Disable all fields on a Web form (ASP.net, HTML forms)

Hi,
 
Today we got a requirement to disable all the fields on the ASP.net form based on some conditions.
 
This can be easily done using JavaScript. Here is the code for it.

var inputs = document.getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
     // For applying background color and color.
     // inputs[i].style.backgroundColor = "#9fd4fe";
     // inputs[i].style.color = "black";
     inputs[i].disabled = true;
}
var selects = document.getElementsByTagName("select");
for (var i = 0; i < selects.length; i++) {
     selects[i].disabled = true;
}
var textareas = document.getElementsByTagName("textarea");
for (var i = 0; i < textareas.length; i++) {
     textareas[i].disabled = true;
}
var buttons = document.getElementsByTagName("button");
for (var i = 0; i < buttons.length; i++) {
     buttons[i].disabled = true;
}
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
     links[i].disabled = true;
}

Hope this helps.
 
--
Happy Coding

Gopinath

Ribbon Workbench Processtrigger With Id = Does Not Exist Issue in CRM

Hi,

Today we got a requirement to hide one of the buttons on Task entity based on some business rule. I have imported Ribbon workbench solution and open the Task entity using Ribbon Workbench. After I am done with the customizing the command, clicked on Publish solution. It took some time and thrown a popup saying the below message.

"Processtrigger With Id = Does Not Exist Issue"

Before it was working fine. I went here and there but could not find anything in CRM. I just recalled the customizations we did on it and some other things we did. Then I realized that recently we have upgraded our CRM to update 0.2.
And found that there was some issue with Customization import where we have business rules.


The quick work around is by changing the scope of Business Rules to "All Forms" resolved the issue.

An issue has already been raised with the Product Team, unfortunately we need to wait until Update 0.3 for the fix.

Hope this helps.

--
Happy CRM'ing

Gopinath

Sunday, 24 January 2016

Remove Locked Field in the Header

Hi,
 
Today, I got a business requirement to remove the Effective from and Effective to fields from the header of the quote.
 
First, I thought that would be very simple to do and opened the Quote form. And noticed that those fields are Locked fields.
 
The work around is very simple.
Add the locked fields on the form. In this case, Effective from and Effective to.

Open the Properties of the field and uncheck Visible by default.

Select the Header on the ribbon and now you will be able to remove the locked fields from the header. You can add the fields as per your requirement.
 Hope this helps.
 
--
Happy CRM'ing

Gopinath

System.InvalidCastException: Unable to cast object of type ‘Microsoft.Xrm.Sdk.Entity’ to type

Hi,
 
Today suddenly all our plugins where we are using early binding thrown exception saying the below message.
 
Unable to cast object of type ‘Microsoft.Xrm.Sdk.Entity’ to type
 
After sometime, fixed the issue by adding the below line in AssemblyInfo.cs of the plugin project.
 
[assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute]

Hope this helps.
 
--
Happy CRM'ing

Gopinath

Saturday, 9 January 2016

Plugin on Merge message in CRM

Hi,
 
Recently, we had a to write a plugin on merge message in CRM. We need to perform some activity based on merged records(Master and Subordinate).
 
Here is the C# code to get the Master and Subordinate entity reference in the plugin code.
 
if (pluginContext.InputParameters.Contains("Target") && pluginContext.InputParameters["Target"] is EntityReference)
{
       EntityReference entityReferenceMaster = (EntityReference)pluginContext.InputParameters["Target"];
       Guid guidSubOrdinate = (Guid)pluginContext.InputParameters["SubordinateId"];

       // Get Master record information. Specify the attributes which you want to retrieve
       Entity entMasterAccount = crmService.Retrieve("account", entityReferenceMaster.Id, new ColumnSet(new string[] {  }));

       // Get Subordinate record information. Specify the attributes which you want to retrieve
       Entity entOrphanAccount = crmService.Retrieve("account", guidSubOrdinate, new ColumnSet(new string[] { }));
}

Hope this helps

--
Happy CRM'ing
Gopinath

Changing security attributes is not allowed in stage 20 plugins

Hi,

Recently we were working on setting Owner of the record in the Pre-Create of the plugin based on our business rules. When we were testing we got the below message. I remember that we did the same in CRM 2013 which used to work properly, some how it is not working in CRM 2015 RTM.

Changing security attributes is not allowed in stage 20 plugins

Moved the code to trigger on Post-Create operation and written a code for assigning a record.

Hope this helps.

--
Happy CRM'ing

Gopinath

Sunday, 3 January 2016

Minimum privileges required to access CRM application

Hi,
 
Today we have a created a new security role in CRM and faced issues when we assigned it to the users.
 
Here is the list of minimum privileges required to access CRM application
 
Entity NamePrivilege(s)   Access LevelSecurity role “Tab” Name
User Entity UI SettingsCreate, Read, WriteUserCore Records
User SettingsReadUserBusiness Management
CustomizationsReadOrganizationCustomization
System FormReadOrganizationCustomization
ViewReadOrganizationCustomization
Web ResourceReadOrganizationCustomization
  • To render the Home page: prvReadWebResource, prvReadCustomization
  • To render an Entity grid (that is, to view lists of records and other data): Read privilege on the entity, prvReadUserSettings, prvReadQuery
  • To view single Entity in detail: Read privilege on the entity, prvReadSystemForm,  prvCreateUserEntityUISettings, prvReadUserEntityUISettings
Hope this helps.
 
--
Happy CRM'ing
Gopinath

Principal user is missing prvReadQuery privilege

Hi,

We have a created a new security role in CRM and given access as per our requirement. When I started testing by assigning the same security role one of the users got the below exception.

Principal user is missing prvReadQuery privilege

This is shown as there is no read permission to the View in the Customization tab.

Hope this helps.

--
Happy CRM'ing

Gopinath

Friday, 1 January 2016

Custom Workflow Input and Output Parmeters in CRM

Hi,
 
Today I got a requirement to create a task and assign it to the Manager of the Owner on the Parent Record. We can easily get the Owner value in the system workflow but not the Manager of the owner.
 
For this I had to write a custom workflow which will take Owner value as an Input Parameter and returns Manager of the Owner as an Output Parameter.
 
Here is the way to declare Input and Output Parameter in a Custom Workflow.
 
/// <summary>
/// Input Argument - SystemUser
/// </summary>
[RequiredArgument]
[Input("User")]
[ReferenceTarget("systemuser")]
public InArgument<EntityReference> User { get; set; }

/// <summary>
/// Output Arugument - Manager of the user.
/// </summary>
[Output("Manager of the user")]
[ReferenceTarget("systemuser")]
public OutArgument<EntityReference> Manager { get; set; }

And this the below code in the Workflow Execute Method.

// Get the Manager of the user.
EntityReference erfUser = User.Get<EntityReference>(executionContext);
Entity entityUser = service.Retrieve("systemuser", erfUser.Id, new ColumnSet(new string[] { "parentsystemuserid" }));
Manager.Set(executionContext, (EntityReference)entityUser.Attributes["parentsystemuserid"]);

After this, just build your project and deploy it in CRM and use the same in the system workflow by passing the Owner value and it will give the Manager of the owner.

In the same way, we can using CRM Custom Workflow for many business operations by using Input and Output Parameters.
 
Hope this helps.
 
--
Happy CRM'ing
Gopinath

Unshare Record in CRM using C#

Hi,

Here is the code for un sharing record in CRM using C# code.

/// <summary>
/// Un shares the Record from Team or User.
/// </summary>
/// <param name="service">CRM Organization Service</param>
/// <param name="erfTargetEntity">Target Entity Reference</param>
/// <param name="erfTeamOrUser">Team or User Entity Reference</param>

public void UnShareRecord(IOrganizationService service, EntityReference erfTargetEntity, EntityReference erfTeamOrUser)
{
       ModifyAccessRequest modif = new ModifyAccessRequest();
       modif.Target = erfTargetEntity;
       PrincipalAccess principal = new PrincipalAccess();
       principal.Principal = erfTeamOrUser;
       principal.AccessMask = AccessRights.None;
       modif.PrincipalAccess = principal;
       ModifyAccessResponse modif_response = (ModifyAccessResponse)service.Execute(modif);
}

Refer this link for sharing record.

Hope this helps.

--
Happy CRM'ing
Gopinath

Sharing Record in CRM using C# Code

Hi,

Here is the code to share a record with a Team or User via C# Code. I have not given Delete Access, as I don't want to give in my requirement. You can check the same and remove/add access accordingly.

/// <summary>
/// Share the Record with the Team or User
/// </summary>
/// <param name="service">CRM Organization Service</param>
/// <param name="erfTargetEntity">Target Entity Reference</param>
/// <param name="erfTeamOrUser">Team or User Entity Reference</param>
public void ShareRecord(IOrganizationService service, EntityReference erfTargetEntity, EntityReference erfTeamOrUser)
{
    // no delete access
    GrantAccessRequest objGrantAccessRequest = new GrantAccessRequest();
    objGrantAccessRequest.Target = erfTargetEntity;
    PrincipalAccess principal = new PrincipalAccess();
    principal.Principal = erfTeamOrUser;
    principal.AccessMask = AccessRights.ReadAccess | AccessRights.AppendAccess | AccessRights.WriteAccess | AccessRights.AppendToAccess | AccessRights.ShareAccess | AccessRights.AssignAccess;
    objGrantAccessRequest.PrincipalAccess = principal;
    GrantAccessResponse grantAccessResponse = (GrantAccessResponse)service.Execute(objGrantAccessRequest);
}


Refer this link for Un sharing a record.

Hope this helps.

--
Happy CRM'ing
Gopinath