Friday, 22 April 2016

The expected parameter has not been supplied for the report (Report render failure. Error: The 'CRM_CalendarType' parameter is missing a value)

Hi,
 
Today when we are trying to run the report for one of the user we are getting error saying
 
"The expected parameter has not been supplied for the report."

 
We did check in the Event Viewer and observed the below error message
 
"The expected parameter has not been supplied for the report."
 
I was pretty sure that there some thing we were missing as I was running OOB report.
 
The solution for this issue is very simple as the user does not have read permission for user settings , report not able to retrieve his calendar details (like Year format)
once assign read permission for User settings everything works fine.
 
  • Click Settings , click Administration , and then click Security Roles .
  • Double-click the security role that you use.
  • On the Business Management tab, set the Read privilege of the User Settings entity at least to the Business Unit level.
  • Click Save and Close.
 
Hope this helps.

--
Happy CRM'ing

Gopinath

Thursday, 14 April 2016

Close Opportunity as Lost in CRM 2011/2013/2015/2016

Hi,
 
Here is the code to close an Opportunity as Lost using the MS Dynamics CRM SDK.
 
In this example, I am using LoseOpportunityRequest to close an Opportunity as Lost.

public static void CloseOpportunityAsLose(IOrganizationService crmService, Guid guidOpportunityId)
{
      LoseOpportunityRequest req = new LoseOpportunityRequest();
      Entity opportunityClose = new Entity("opportunityclose");
      opportunityClose.Attributes.Add("opportunityid", new EntityReference("opportunity", guidOpportunityId));
      opportunityClose.Attributes.Add("subject", "Lost the Opportunity!");
      req.OpportunityClose = opportunityClose;
      OptionSetValue osvLostValue = new OptionSetValue();
      osvLostValue.Value = 4;
      req.Status = osvLostValue;
      LoseOpportunityResponse resp = (LoseOpportunityResponse)crmService.Execute(req);
}

Hope this helps.
 
--
Happy CRM'ing

Gopinath

 

Close Opportunity as Won in CRM 2011/2013/2015/2016

Hi,
 
Here is the code to close an Opportunity as Won using the MS Dynamics CRM SDK.
 
In this example, I am using WinOpportunityRequest to close an Opportunity as Won.

public static void CloseOpportunityAsWon(IOrganizationService crmService, Guid guidOpportunityId)
{
       WinOpportunityRequest req = new WinOpportunityRequest();
       Entity opportunityClose = new Entity("opportunityclose");
       opportunityClose.Attributes.Add("opportunityid", new EntityReference("opportunity", guidOpportunityId));
       opportunityClose.Attributes.Add("subject", "Won the Opportunity!");
       req.OpportunityClose = opportunityClose;
       OptionSetValue osvWon = new OptionSetValue();
       osvWon.Value = 3;
       req.Status = osvWon;
       WinOpportunityResponse resp = (WinOpportunityResponse)crmService.Execute(req);
}

Hope this helps.
 
--
Happy CRM'ing

Gopinath

 

Tuesday, 12 April 2016

C# Code for Removing Security Role to a User - CRM 2011/2013/2015/2016

Hi,

In the last post we have seen how to assign a security role to the user programmatically.

Here is the code for removing the security roles of the users.

public void RemoveUserSecurityRole(Guid guidSystemUserId, Guid guidSecurityRoleId, IOrganizationService crmService)
{
         // Create new Disassociate Request object for creating a N:N link between User and Security
         DisassociateRequest objDisassociateRequest = new DisassociateRequest();
         // Create related entity reference object for associating relationship
         // we will pass System User record reference of user for which the role is required to be removed 
         objDisassociateRequest.RelatedEntities = new EntityReferenceCollection();
         objDisassociateRequest.RelatedEntities.Add(new EntityReference("systemuser", guidSystemUserId));
        // Create new Relationship object for System User & Security Role entity schema and assigning it 
        // to request relationship property
        objDisassociateRequest.Relationship = new Relationship("systemuserroles_association");
        // Create target entity reference object for associating relationship
        objDisassociateRequest.Target = new EntityReference("role", guidSecurityRoleId);
        // Passing DisassociateRequest object to Crm Service Execute method for removing Security Role to User
        crmService.Execute(objDisassociateRequest);
}

Hope this helps.

--
Happy CRM'ing
Gopinath

C# Code for Assigning Security Role to a User - CRM 2011/2013/2015/2016

Hi,

Today we got a requirement to assign Security Role to a user. We all know that Security Roles are associated with User via N:N relationship and relationship name is systemuserroles_association.

We can use AssociateRequest to assign the security roles to the user programmatically.

Here is the C# code for assigning a security role to a user.

public void AssignSecurityRole(Guid guidSystemUserId, Guid guidSecurityRoleId, IOrganizationService crmService)
{
        // Create new Associate Request object for creating a N:N relationsip between User and Security
        AssociateRequest objAssociateRequest = new AssociateRequest();
        // Create related entity reference object for associating relationship
        // In this case we SystemUser entity reference  
        objAssociateRequest.RelatedEntities = new EntityReferenceCollection();
        objAssociateRequest.RelatedEntities.Add(new EntityReference("systemuser", guidSystemUserId));
        // Create new Relationship object for System User & Security Role entity schema and assigning it 
        // to request relationship property
        objAssociateRequest.Relationship = new Relationship("systemuserroles_association");
        // Create target entity reference object for associating relationship
        objAssociateRequest.Target = new EntityReference("role", guidSecurityRoleId);
        // Passing AssosiateRequest object to Crm Service Execute method for assigning Security Role to User
        crmService.Execute(objAssociateRequest);
}

Hope this helps.

--
Happy CRM'ing

Gopinath

Saturday, 9 April 2016

An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework

Hi,
 
Today we have deployed some of our .exe's and dlls on the server and when we ran the .exe we were getting the below exception.
 
"An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework"
 
I did check the .net versions and found all the things are absolutely fine. After sometime, came to know that the dll was blocked on the server.
 
To unblock the DLL or EXE,
 
Right click on DLL or EXE --> choose Properties --> click the Unblock button --> Apply and Ok.
 
The reason behind this blocking is normally operating system will blocks the DLL if it is copied from a network location because of security reasons.
 
Hope this helps.
 
--
Cheers,

Gopinath

Friday, 8 April 2016

Disable Send Report to Microsoft pop up - Microsoft Dynamics CRM has encountered an error

HI,

In CRM we get many error reports showing the below popup. We can hide this by changing a small setting in CRM.

Settings -> Administration -> Privacy Preferences -> Select Error Reporting and Select "Never send an error report to Microsoft"
 
 

Hope this helps.

--
Happy CRM'ing

Gopinath