web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Unable to update "Choose Product" field on Opportunity Product line form

(0) ShareShare
ReportReport
Posted on by 80

Hi there,

One of our team member has wrongly mapped "Choose Product" field on opportunityproduct entity while importing the data. We realized it later and we are trying to update the field with actual Products from product entity. 

Here is the code that we are using to update the "choose product" field.

Entity entity = new Entity("opportunityproduct")
{
Id = new Guid(dr["(Do Not Modify) Opportunity Product"].ToString())
};
entity["productid"] = new EntityReference("product", new Guid(dr["productid"].ToString()));
_orgService.Update(entity);

But for some reason, we are getting "Entity Reference cannot have Id and Key Attributes empty" error. Below the stack trace.

System.ServiceModel.FaultException`1
HResult=0x80131501
Message=Entity Reference cannot have Id and Key Attributes empty.
Source=mscorlib
StackTrace:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.Update(Entity entity)
at Microsoft.Xrm.Sdk.WebServiceClient.OrganizationWebProxyClient.<>c__DisplayClass38_0.<UpdateCore>b__0()
at Microsoft.Xrm.Sdk.WebServiceClient.WebProxyClient`1.ExecuteAction(Action action)
at Microsoft.Xrm.Sdk.WebServiceClient.OrganizationWebProxyClient.UpdateCore(Entity entity)
at Microsoft.Xrm.Sdk.WebServiceClient.OrganizationWebProxyClient.Update(Entity entity)
at ConsoleApp2.Program.Main(String[] args) in C:\ConsoleApp2\Program.cs:line 28

Can somebody please help if i am doing anything wrong.

Thanks,

Venu

I have the same question (0)
  • Suggested answer
    Nya Profile Picture
    29,060 on at

    Hi Venu,

    Please refer to the answer in the following issue, which is similar to yours.

    (+) ID of an entity does not exist - Microsoft Dynamics CRM Forum Community Forum

  • Vallamreddy VenuGopal Profile Picture
    80 on at

    Thanks Nya for your response.

    My solution is not a Plugin Assembly, it's a console application. We have few records that needed to be updated to a new product and chose the way of console app to update these records. Means, in our case the record already exists and the error is completely different what the above thread discussed about.

    Regards,

    Venu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 74

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans