Hi,
Trying to create an opportunity using the Dynamics 365 v9 SDK. I can create other objects fine, like PriceLevel and Account, but cannot create an opportunity.
using (var _serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null))
{
var _service = (IOrganizationService)_serviceProxy;
_serviceProxy.EnableProxyTypes();
var pricelevel2 = _service.Retrieve("pricelevel", Guid.Parse(price_level_id), new ColumnSet(true));
var owner = _service.Retrieve("systemuser", Guid.Parse(system_user_id), new ColumnSet(true));
var _account = _service.Retrieve("account", Guid.Parse(account_id), new ColumnSet(true));
Opportunity newOpportunity = new Opportunity
{
Id = Guid.NewGuid(),
OpportunityId = Guid.NewGuid(),
Name = "Example Opportunity",
PriceLevelId = pricelevel2.ToEntityReference(),
OwnerId = owner.ToEntityReference(),
CustomerId = _account.ToEntityReference(),
ParentAccountId = _account.ToEntityReference(),
EntityState = EntityState.Created,
IsRevenueSystemCalculated = false,
EstimatedValue = new Money(400.00m),
FreightAmount = new Money(10.00m),
DiscountAmount = new Money(0.10m),
DiscountPercentage = 0.20m
};
var _opportunityId = _serviceProxy.Create(newOpportunity);
}
I get an error "Nullable object must have a value.'" but I have checked the Opportunity object at https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/entities/opportunity#entity-properties and all SystemRequired objects should be filled in.
*This post is locked for comments
I have the same question (0)