marți, 7 iulie 2015

The SELECT permission was denied on the object 'EntityView', database 'Fashion_MSCRM', schema 'dbo'.

Sometimes, when you create or import a new CRM Organization, the new CRM Organization does not work..

If you take a look in Event Viewer, you will see a message like : The SELECT permission was denied on the object 'EntityView', database 'Fashion_MSCRM', schema 'dbo'.

For this, you can give explicit permissions on that object :

GRANT SELECT ON dbo.EntityView
TO [CRMReaderRole]
GO


Or, if you give that permission, and its still requires more permissions, for other objects, you can do it like :

EXEC sp_addrolemember N'db_owner', N'CRMReaderRole'
GO

joi, 21 mai 2015

How to install an older version of package via NuGet

In Package Manager Console, type :

Install-Package -Id Microsoft.CrmSdk.CoreTools -ProjectName FashionCompany.TestImportConsoleApplication -Version 7.0.1

marți, 5 mai 2015

Using Update in CRM 2015 to set the State and Status of entities

Today I managed to waste at least one hour, because I tried to use a new feature from the SDK of 2015.
Basically, I tried to create a simple account, then deactivate it.

the code :

            Entity account = new Entity("account");
            account["name"] = "FreeAcademy";
            Guid id = CrmOrganizationService.Create(account);
       
            account["accountid"] = id;
            account["statecode"] = new OptionSetValue(1); // inactive
            account["statuscode"] = new OptionSetValue(2);

            CrmOrganizationService.Update(account);

I received a nice exception message :

2 is not a valid status code for state code AccountState.Active on account with Id 7f21fa89-45f3-e411-9430-005056bd3a00.

On MSDN, it says like this : For Microsoft Dynamics CRM Online organizations, this feature is available only if your organization has updated to Dynamics CRM Online 2015 Update 1. This feature is not available for Dynamics CRM (on-premises).

So, take into account that if you are using an On-premise deployment, the piece of code from above will not work.

Happy Coding !

joi, 26 februarie 2015

How to use early bound entities in the context of an workflow

How to use early bound entities in the context of an workflow :

IWorkflowContext context = executionContext.GetExtension();

IOrganizationServiceFactory serviceFactory = executionContext.GetExtension();

//YourServiceContext = the name of crm context 
var type = Type.GetType("Microsoft.Crm.Workflow.SynchronousRuntime.WorkflowContext, Microsoft.Crm.Workflow, Version=5.0.0.0"); 

type.GetProperty("ProxyTypesAssembly").SetValue(serviceFactory,typeof(YourServiceContext).Assembly, null); IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);