Answered by:
CRM 2011 plugin error: Query builder error, the specified record type does not exist in Microsoft Dynamics CRM

Question
-
In one of my custom entity I need to set up a campaign entity, which is a look up in my custom entity. When I am trying to set this in plugin I am getting this query build error.
My code looks follows: It is getting the correct campaign, while saving the changes it is giving that error
Entity
entity = (Entity)pluginExecContext.InputParameters["Target"];
varcampaign = GetCampaignID();
EntityReferencecampaignRef = newEntityReference("Campaign", campaign.Id);
entity.Attributes.Add(
"cdi_campaignid", campaignRef);
orgServiceContext.SaveChanges();
Monday, January 7, 2013 2:52 PM
Answers
-
Thanks for the reply, I resolved the problem by changing the new EntityReference("campaign", campaign.Id) to newEntityReference(Campaign.EntityLogicalName, campaign.Id) and instead of calling orgServiceContext.SaveChanges() to OrgService.Update(entity).
- Marked as answer by RhettClintonMVP, Moderator Tuesday, January 8, 2013 10:17 PM
Tuesday, January 8, 2013 8:44 PM
All replies
-
EntityReferencecampaignRef = newEntityReference("Campaign", campaign.Id);
This should be the following I think.
EntityReferencecampaignRef = newEntityReference("campaign", campaign.Id);
I'm not sure why you are calling orgServiceContext.SaveChanges(); but if you have this plugin in the prestage mode transaction you only need to update your inputparameter entity for the campaign value to be saved using the standard system save.
MS CRM Bing'd - http://bingsoft.wordpress.com Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool CRM 2011 OData Query Designer CRM 2011 Metadata Browser CRM Forum Guidance - Proposed as answer by HIMBAPModerator Monday, January 7, 2013 5:07 PM
Monday, January 7, 2013 3:40 PMModerator -
check
if(entity.attrribute.contain("campaign"))
entity["campaign"]="";
else
{
entity.Attributes.Add("cdi_campaignid", campaignRef);}
fire this in pre-operation stage ,message=update
if like to update the entity
ms crm
Monday, January 7, 2013 3:45 PM -
Thanks for the reply, I resolved the problem by changing the new EntityReference("campaign", campaign.Id) to newEntityReference(Campaign.EntityLogicalName, campaign.Id) and instead of calling orgServiceContext.SaveChanges() to OrgService.Update(entity).
- Marked as answer by RhettClintonMVP, Moderator Tuesday, January 8, 2013 10:17 PM
Tuesday, January 8, 2013 8:44 PM -
Hi,
i am also facing the same issue,in Microsoft dynamics crm.In the Sales pane i have added the "Notes" entity by editing the customizations file. now the "Notes" entity is displaying in the sales pane. Earlier it is worked fine, when the crm is upgraded to Polaris version it is this error. then, while i am clicking on 'new' button it is displaying the following error.
how to resolve this error. any help will be greatly appreciated.
Thanks in Advance.Nagaraj
Tuesday, February 19, 2013 11:40 AM -
" changing the new EntityReference("campaign", campaign.Id) tonewEntityReference(Campaign.EntityLogicalName, campaign.Id)" only will do.
Thank you for the post :)Friday, April 8, 2016 2:32 AM