Showing posts with label CRM 2011/2013/2015. Show all posts
Showing posts with label CRM 2011/2013/2015. Show all posts

Saturday, 19 March 2016

Move records automatically to Owner's Queue

Hi,

Today, we got a requirement from Customers to all the Tasks created in the system should move to the Owner's respective queue. Then we were thinking of the custom approach and then we got a doubt it should be available in OOB CRM with some configuration settings. After checking, yes it is available.

Go to Customizations -> Entity Information -> Tick the check box which is available just below the Queues as shown in the figure.

Hope this helps.
--
Happy CRM'ing

Gopinath

Tuesday, 8 March 2016

Wrong type of attribute UI properties passed to the attribute


Today when are trying to Merge got below error message and there is no log file also to download. Disabled all the plugins, JavaScript on Account entity and tried again but the same error message popped up.

Hence confirmed that there is something other than plugins and custom JavaScript. Went ahead started debugging the OOB JavaScript on Merge button click and got the below error message.
Wrong type of attribute UI properties passed to the attribute "attribute name"

Then understood the problem, we have created a custom field with Whole Number as a datatype and then we realized that the field should be of type Two Options. We have deleted the field and created the field with the same schema name.

Solution
1) Remove the field on the form.
2) Save and Publish the form.
3) Add the field back on the form.
4) Save and Publish the form.


Note - I would recommend to not to delete the fields and create again with the same schema. We never know where will it hit us back. Better set the Searchable property to No to the old field and rename it to Do Not Use and create a field with new schema name.

--
Happy CRM'ing
Gopinath

Sunday, 24 January 2016

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

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

Monday, 7 December 2015

Stages, Stages Number and their use in CRM Plugins

Hi,

Sometimes we might get the chance to use only one Plugin on different and it would have separate business logic to perform on different stages.

Here is the table which shows the associated stage number with the stage name and the event.
EventStage NameStage NumberDescription
Pre-Event
Pre-validation10Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage may execute outside the database transaction.
Pre-EventPre-operation20Stage in the pipeline for plug-ins that are to execute before the main system operation. Plug-ins registered in this stage are executed within the database transaction.
Post-EventPost-operation40Stage in the pipeline for plug-ins which are to execute after the main operation. Plug-ins registered in this stage are executed within the database transaction.

We can use this numbers as conditions in the plugin as shown below.

You might be thinking why 30 is missing in the middle. We do have 30 but it is for main operation which we cannot use in the custom plugins.

Platform Core OperationMain Operation30In-transaction main operation of the system, such as create, update, delete, and so on. No custom plug-ins can be registered in this stage. For internal use only.

Hope this helps.

--
Happy CRM'ing

Gopinath