Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 137182

Forum Post: RE: Cannot Create Opportunity, Nullable object must have a value.

$
0
0
I never liked early-binding. Here is almost the same code written using late-binding and it works fine for me: var opportunity = new Entity("opportunity") { ["name"] = "Example Opportunity", ["pricelevelid"] = priceLevel.ToEntityReference(), ["customerid"] = account.ToEntityReference(), ["parentaccountid"] = account.ToEntityReference(), ["isrevenuesystemcalculated"] = false, ["estimatedvalue"] = new Money(400m), ["freightamount"] = new Money(10m), ["discountamount"] = new Money(0.1m), ["discountpercentage"] = 0.2m }; var oppId = service.Create(opportunity); Regarding why your code doesn't work... try to remove following lines: Id = Guid.NewGuid(), OpportunityId = Guid.NewGuid(), and EntityState = EntityState.Created,

Viewing all articles
Browse latest Browse all 137182

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>