Creating Entity with an invalid parent exception. Entity : Email, ReferencingAttribute:regardingobjectid in CRM 2011.


We got this error while trying to send email programmatically. The issue was we were setting regarding object id as one of the entity for which Email was not enabled.


Hope it helps.

SecurityException: Request for the permission of type “System.Security.Permissions.EnvironmentPermission” failed in CRM 2011 plugin.

We will get this error while using Environment.MachineName
in our plugin code to get the Server Name in case of Sandbox.


Security Exception: That assembly does not allow partially trusted callers in CRM 2011 plugin.


We were getting the below error in one of our plugins. The reason was because we were making use of HttpContext class of System.Web assembly.

For our on-premise deployment it was working fine, we were getting this issue only on registering plugin on Sandbox mode.

We can find the explanation here


Four Nested If Limitations on workflows in CRM.


We recently had a requirement to write a workflow that would require nested if conditions. Much to our surprise we realized that only 4 nested if conditions are supported.

After selecting “Select this row for “IF 5″and clicking on “Add Step”, we can see the Add Step menu greyed out.

The workaround is to use Child Workflow.

Check out this wonderful article

Hope it helps.

Using multiple JavaScriptFunction for Actions in CRM 2011 Ribbon.


We had a requirement in which we wanted to add some functionality on the existing Distribute Campaign Activity button for Campaign Activity entity.

For e.g. before we start the distribution we wanted to check for a specific value for all the Marketing Lists associated to that Campaign Activity. Based on it we wanted to proceed further or stop the distribution.

So we created a new custom button using the same definitions used for the existing Distribute Campaign Activity button (i.e. same CommandDefinitions and RuleDefinitions). The only thing we added was the new JavaScriptFunction in the Actions menu. It was referring to the function name CheckMLUA inside the webresource name new_CheckML

Now inside this new JavaScriptFunction we wanted to call the CallDistribute function that is being used by the OOB Distribute Campaign Activity button

For this to work we defined the FunctionName as isNAN for campaignactivity.js.

“For each library, add a <JavaScriptFunction Library=”$webresource:webresourceName” FunctionName=”isNaN” /> node. It requires a function name, so we’ve just been putting isNaN in there so there’s no error.”

FunctionName=CheckMLUA />


Value=PrimaryEntityTypeCode />


And our function


 <CustomAction Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.CustomAction" Location="Mscrm.Form.campaignactivity.MainTab.Actions.Controls._children" Sequence="41">
 <Button Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute" Command="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Command" Sequence="0" ToolTipTitle="$LocLabels:WWB.Form.campaignactivity.MainTab.Actions.Distribute.LabelText" LabelText="$LocLabels:WWB.Form.campaignactivity.MainTab.Actions.Distribute.LabelText" ToolTipDescription="$LocLabels:WWB.Form.campaignactivity.MainTab.Actions.Distribute.Description" TemplateAlias="o1" Image16by16="/_imgs/MA/CampaignActivityDistribute_16.png" Image32by32="/_imgs/MA/CampaignActivityDistribute_32.png" />
 <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
 <CommandDefinition Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Command">
 <EnableRule Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Command.EnableRule.FormStateRule" />
 <DisplayRule Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Command.DisplayRule.EntityPrivilegeRule" />
 <JavaScriptFunction Library="$webresource:new_CheckML" FunctionName="CheckMLUA" />
 <JavaScriptFunction FunctionName="isNaN" Library="/_static/ma/campaignactivity/campaignactivity.js">
 <CrmParameter Value="PrimaryEntityTypeCode" />
 <TabDisplayRules />
 <DisplayRule Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Command.DisplayRule.EntityPrivilegeRule">
 <EntityPrivilegeRule EntityName="activitypointer" PrivilegeDepth="Basic" PrivilegeType="Create" />
 <EnableRule Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Command.EnableRule.FormStateRule">
 <FormStateRule State="Existing" />
 <LocLabel Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.Description">
 <Title languagecode="1033" description="Distribute Description" />
 <LocLabel Id="WWB.Form.campaignactivity.MainTab.Actions.Distribute.LabelText">
 <Title languagecode="1033" description="Distribute" />

The helpful links


Writing a Plugin on “Distribute Campaign Activity” message in CRM.


We recently had a requirement to execute a plugin  when a CampaignActivity is distributed using “Distribute Campaign Activity” button.

As it turned out, this message was not available.

As it was on premise, we enabled it in an unsupported manner i.e. by updating the sdkmessagefilterbase table in orgname_mscrm database.

SQL Query Used :-

update sdkmessagefilterbase

set isCustomProcessingStepAllowed=1


sdkmessageid=(select sdkmessageid from sdkmessagebase where name=‘DistributeCampaignActivity’)



Hope this helps.