Answered by:
Not able to create a sales order detail using CRM 4.0 webservice

Question
-
I am getting server unable to process the request....
crm.salesorderdetail _salesOrderdetail = new crm.salesorderdetail();
_salesOrderdetail.productid = new crm.Lookup();
_salesOrderdetail.productid.type = EntityName.product.ToString();
_salesOrderdetail.productid.Value = crmproductId;
_salesOrderdetail.salesorderid = new crm.Lookup();
_salesOrderdetail.salesorderid.type = EntityName.salesorder.ToString();
_salesOrderdetail.salesorderid.Value = CrmSalesOrderId;
_salesOrderdetail.createdby = new crm.Lookup();
_salesOrderdetail.createdby.type = EntityName.systemuser.ToString();
_salesOrderdetail.createdby.Value = new Guid( "A7B9791D-189E-DE11-B14E-0016357F6127" );
_salesOrderdetail.overriddencreatedon = new crm.CrmDateTime();
_salesOrderdetail.overriddencreatedon.date = .OrderDate;_salesOrderdetail.lineitemnumber = new crm.CrmNumber();
_salesOrderdetail.lineitemnumber.Value =1;_salesOrderdetail.priceperunit = new crm.CrmMoney();
decimal PriceExclusiveVAT = 0;
bool result3 = decimal.TryParse( PriceExclusiveVAT, out PriceExclusiveVAT );
_salesOrderdetail.priceperunit.Value = PriceExclusiveVAT;
_salesOrderdetail.quantity = new crm.CrmDecimal();
decimal quantity = 0;
bool result4 = decimal.TryParse( Quantity, out quantity );
_salesOrderdetail.quantity.Value = quantity;_salesOrderdetail.tax = new crm.CrmMoney();
decimal tax = 0;
bool result5 = decimal.TryParse( VATAmount[0], out tax );
_salesOrderdetail.tax.Value = tax;
crm.Create( _salesOrderdetail );Wednesday, September 16, 2009 10:28 AM
Answers
-
Hi.
So this is the source of error fill the field unit id and everything will work =)
Truth is opened the prepared mind My blog - http://a33ik.blogspot.com- Proposed as answer by ckeller Wednesday, September 16, 2009 10:53 AM
- Marked as answer by DavidJennawayMVP, Moderator Friday, October 23, 2009 12:38 PM
Wednesday, September 16, 2009 10:43 AMModerator
All replies
-
Hi.
Try to cover
crm.Create( _salesOrderdetail );
line with try catch code and read an Exception like:
try
{
crm.Create( _salesOrderdetail );
}
catch (SoapException ex)
{
throw new Exception(ex.Detail.InnerText);
}
Truth is opened the prepared mind My blog - http://a33ik.blogspot.comWednesday, September 16, 2009 10:32 AMModerator -
Hi ..
When I debugged the inner exception was Nothing.Wednesday, September 16, 2009 10:33 AM -
Hi.
Have you used exactly my code?
Truth is opened the prepared mind My blog - http://a33ik.blogspot.comWednesday, September 16, 2009 10:34 AMModerator -
This time I used your catch method and got the below
0x80043b0d
The unit id is missing.
PlatformWednesday, September 16, 2009 10:40 AM -
Hi.
So this is the source of error fill the field unit id and everything will work =)
Truth is opened the prepared mind My blog - http://a33ik.blogspot.com- Proposed as answer by ckeller Wednesday, September 16, 2009 10:53 AM
- Marked as answer by DavidJennawayMVP, Moderator Friday, October 23, 2009 12:38 PM
Wednesday, September 16, 2009 10:43 AMModerator -
Gentle Man.. Thanks a Lot . It worked after I gave uom field. Finally I landed at the right Forum for CRM DevWednesday, September 16, 2009 10:48 AM
-
Hi I have been looking for a plug-in that will create a sales order detail record. Every month (till service end-date), a workflow creates an order and need to create sales order detail record (but wf couldn't do) in crm 2011 online. I would need to create a plug-in that would create the realated sales order detail. I am thinking of creating a custom entity (A) and have a plug-in that runs on this custom entity to insert a record in sales order detail.
- Workflow creates order record (once every month)
- creates sales order detail record in entity A
- plug-in (running on A) takes the record and insert into sales order detail
Appreciate if you could help with a code and / or suggest if this will work (or any other approach). Thanks a lot.
Monday, February 21, 2011 10:34 PM