One or more of the option values for this picklist are not in the range of allowed values in CRM 4


Hi,

I started getting this issue on one of our entities while saving it.

This wasn’t the issue in CRM 3.0, this issue came up only after upgrading to CRM 4.0.

I was sure that the issue is because of some picklist getting filled up with dynamic options. But what was surprising was it was working perfectly fine in CRM 3.0.

After looking for it , i realized that the above error only comes in CRM 4.0, in CRM 3.0, it doesn’t throw error and we are also able to save the form.

So i thought of trying out these two options for correcting the error in CRM 4.0,

1) Dynamically disabled the field using JavaScript on the onSave and enabling it on onLoad. Disabled field’s value wouldn’t be passed to the CRM Platform so i thought this would resolve my issue. For update it worked, however it didn’t work for new form.

2) Than i thought of writing a plugin that on pre create or pre update event would remove the picklist field from being passed as an inputparameter to the CRM Platform. However the error showed up before we could even reach the pre-create plugin.

So finally added few options through customization section and on the onload removed that option using DeleteOption for the picklist. And than i was able to work with that picklist properly and was also able to solve the form

bye.

Understanding workflowContext.MessageName of IWorkflowContext interface in CRM workflow activity.


Hi,

Today i was trying to find out what could be the different values for it.

So i had my custom workflow activity registered against all the triggering conditions.

i.e. Record is created, record status changes, record is assigned, record attribute change and record is deleted.

Well these were my findings

for record is created the message name was “Create”

for record status changes, record is assigned, record attribute change it was “Update”.

for record is deleted it was “Delete”.

And one more thing if we have selected both the conditions i.e. record attribute change and record is assigned,  owner field within record attribute change gets auto selected.

bye.

0x80040216 An unexpected error occurred Platform while sending mail through custom workflow activity in CRM 4


Hi,

We were getting the below error

<error>

  <code>0x80040216</code>

  <description>An unexpected error occurred.</description>

  <type>Platform</type>

</error>

on our custom workflow activity for the following requests

SendEmailRequest

SendEmailFromTemplateRequest

This is how we were creating the CrmService instance

workflowContext.CreateCrmService(true);

however later we changed it to

workflowContext.CreateCrmService();

and the error got resolved.

 

CreateCrmService(bool asAdminUser):

Both of these methods return an ICrmService interface. This is optimal way to interact with CRM to execute the various requests in the CRM web service. The overload allows you to execute with more privileges if needed; just in case the current user doesn’t have the required privileges to perform some action in your custom business logic.

More on IWorkflowContext interface

http://blogs.msdn.com/crm/archive/2009/06/24/microsoft-dynamics-crm-4-0-iworkflowcontext-interface.aspx

bye.

Calling form’s JavaScript functions in ISV.CONFIG


Hi,

We had a requirement to check for user’s role on click of one of the isv.config button. So we thought of using JavaScript attribute of the button.

This is one of the very good article about how to use javascript for checking the roles

http://jianwang.blogspot.com/2008/01/crm-40-check-current-users-security.html

However using JavaScript within ISV.Config has its own share of trouble as it is an xml file, so we need to replace so many characters within it and moreover this has to be done very carefully.

So what we decided that we’d put the JavaScript code in the entity’s form’s onload event and would simply call that function within isv.config, than we wouldn’t have to replace characters within JavaScript for making them xml specific.

So suppose this is the JavaScript function

function UserHasRole(roleName)
{
 //get Current User Roles, oXml is an object
 var oXml = GetCurrentUserRoles();
 if(oXml != null)
 {
  //select the node text
  var roles = oXml.selectNodes("//BusinessEntity/q1:name");
  if(roles != null)
  {
   for( i = 0; i < roles.length; i++)
   {
    if(roles[i].text == roleName)
    {
     //return true if user has this role
     return true;
    }
   }
  }
 }
 //otherwise return false
 return false;
}

 

Now to make it reusable, so that we could call it within isv.config we just need to change its declaration

from

function UserHasRole(roleName)

{

// function body

}

to

UserHasRole=function(roleName)

{

// function body

}

and put it in the form’s onload event javascript.

And to call it within Button’s JavaScript –>

UserHasRole(‘System Administrator’)

Just like a normal function !!

 

Bye…

Set ActivityParty for DynamicEntity


Hi,

To set activityparty property in case of DynamicEntity we need to make use DynamicEntityArrayProperty.

Below is the sample code for creating an appointment programmatically using DynamicEntity and setting requiredattendees which is an ActivityParty property.

CrmSdk.CrmAuthenticationToken myToken = new CrmAuthenticationToken();

        myToken.OrganizationName = "orgname";

        myToken.AuthenticationType = 0;

        CrmSdk.CrmService myService = new CrmService();

        myService.CrmAuthenticationTokenValue = myToken;

        myService.Credentials = System.Net.CredentialCache.DefaultCredentials;

        DynamicEntity myAppointment = new DynamicEntity();

        myAppointment.Name = EntityName.appointment.ToString();

        StringProperty subject = new StringProperty();

        subject.Name = "subject";

        subject.Value = "Test Subject";

        // Set a contact for party

        DynamicEntity requiredAtt1 = new DynamicEntity();

        requiredAtt1.Name = "activityparty";

        // create a contact property

        LookupProperty contactProp = new LookupProperty();

        contactProp.Name = "partyid";

        Lookup contactLookup = new Lookup();

        contactLookup.type = "contact";

        contactLookup.Value = new Guid("{2DE7671B-987D-DE11-8AB8-0003FFD21C1C}");

        contactProp.Value = contactLookup;

        // add contact property

        requiredAtt1.Properties = new Property[] { contactProp };

        // Set an account for party

        DynamicEntity requiredAtt2 = new DynamicEntity();

        requiredAtt2.Name = "activityparty";

        // create an account property

        LookupProperty accountProp = new LookupProperty();

        accountProp.Name = "partyid";

        Lookup accountLookup = new Lookup();

        accountLookup.type = "contact";

        accountLookup.Value = new Guid("{A4BB3561-748D-DE11-8CD4-0003FFD21C1C}");

        accountProp.Value = accountLookup;

        // add account property

        requiredAtt2.Properties = new Property[] { accountProp };

        // create to property. it is an dynamic entity array

        DynamicEntityArrayProperty raProp= new DynamicEntityArrayProperty();

        raProp.Name = "requiredattendees";

        // add contact and account activity parties

        raProp.Value = new DynamicEntity[] { requiredAtt1, requiredAtt2 };

        // set scheduledStart date

        CrmDateTimeProperty scheduledStart = new CrmDateTimeProperty();

        scheduledStart.Name = "scheduledstart";

        CrmDateTime ss = new CrmDateTime();

        ss.Value = DateTime.Now.ToString();

        scheduledStart.Value = ss;

        // set scheduledend date

        CrmDateTimeProperty scheduledEnd = new CrmDateTimeProperty();

        scheduledEnd.Name = "scheduledend";

        CrmDateTime se = new CrmDateTime();

        se.Value = DateTime.Now.AddHours(1).ToString();

        scheduledEnd.Value = se;        

        myAppointment.Properties = new Property[] { subject,raProp, scheduledStart,scheduledEnd };

        Guid mycontactGuid = new Guid();

        try

        {

            mycontactGuid = myService.Create(myAppointment);

        }

        catch (SoapException ex)

        {

         //   handle exception

        }

Bye..

The ‘System.ServiceModel/ServiceHostingEnvironment’ configuration section cannot be created. The Machine.config file is missing information error on opening CRM


Hi,

I got this error while opening CRM 4 !

The solution was to run the following command

ServiceModelReg.exe –i

which could be found at

C:Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation.

Followed by an IISReset.

However in few cases to resolve it, it requires reinstallation of IIS.

ServiceModel Registration tool with -i option

Registers this version of WCF and update scriptmaps at the Internet Information Services (IIS) metabase root and for all scriptmaps under the root. Existing scriptmaps of lower versions are upgraded to this version.

 

Bye.