Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Error, when creating invoicedetail/ Invoice (Product) with plugin in CRM 2011

$
0
0

             Hi,

             I'm trying to add a product to an invoice via plugin in CRM 2011, but the plugin gives an error. Inside the error there is the message: <Message>The parent id is missing.</Message>.

Here I create the invoice and it works fine:

                        Entity invoiceRecord = new Entity("invoice");
                        invoiceRecord["name"] = "Sample Invoice";
                        invoiceRecord["customerid"] = new EntityReference("account", regardingobjectidAccount);
                        invoiceRecord["pricelevelid"] = new EntityReference("pricelevel", PriceListGUID); 
                        RegardingobjectidInvoice = service.Create(invoiceRecord);

And here I want to create the product, which should be related to the invoice above:

                        Entity invoiceProduct = new Entity("invoicedetail");
                        invoiceProduct["productid"] = new EntityReference("product", ProductGUID);
                        invoiceProduct["quantity"] = 1;
                        invoiceProduct["invoiceid"] =invoiceRecord.ToEntityReference();
                        invoiceProduct["UoMId"] = new EntityReference("UoM", UoMGUID);
                        service.Create(invoiceProduct);

In this line there is obviously an error: 
invoiceRecord["invoiceid"] = invoiceRecord.ToEntityReference();

Can anybody help me with it?



Viewing all articles
Browse latest Browse all 8223

Trending Articles



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