Friday, July 17, 2009

Create Invoice in CRM 4.0 / 3.0

service = CLM_CRM_Service.GetCrmService();
invoice objInvoice = new invoice();
invioceName = accountName + " - Invoice Processed For Month - " + critiria[0].ToString() + " " + critiria[1].ToString();
objInvoice.name = invioceName;
Customer customerid = new Customer();
customerid.Value = new Guid(accountId);
customerid.type = EntityName.account.ToString();
objInvoice.customerid = customerid;
objInvoice.ownerid = new Owner();
objInvoice.ownerid.Value = new Guid(ownerID); // new Guid("C3182C2C-C266-DE11-A541-001E0B5E0BF6");//system userid
objInvoice.ownerid.type = EntityName.systemuser.ToString();
objInvoice.pricelevelid = new Lookup();
objInvoice.pricelevelid.Value = new Guid(RetrievePriceLevel());
objInvoice.pricelevelid.type = EntityName.pricelevel.ToString();
CrmBoolean objSync = new CrmBoolean();
objSync.Value = true;
objInvoice.new_issynchronized = objSync;
Guid invoiceId = service.Create(objInvoice);

No comments: