none
how to create invoice entity using plugin, ms crm 2011 ?

    Question

  • hi,

    im trying to create an "invoice" record using plugin. here is my code.

                    Entity newentity = new Entity("invoice");
                    newentity["name"] = "Something";
                    service.Create(newentity);

    im getting business process error.  when i use the same code to create account record, record is getting created.

    when i debug this plugin, getting exception because of last line (ie:, service.Create(newentity)).

    is it not possible to create "invoice" record using plugin.? 

    or is there any other way to create "invoice" record using plugin.? 

    any suggestions to create invoice record using plugin ?

    here is the error message.

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An error occurred in the plug-in.Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220891</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>OperationStatus</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>An error occurred in the plug-in.</Message>
      <Timestamp>2012-08-26T12:36:48.2753906Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText>

    [Invoice: NewInvoice.MyPlugin]
    [10160e12-76ef-e111-b84a-000c2944d8a5: NewInvoice.MyPlugin: Update of new_entity]


    </TraceText>
    </OrganizationServiceFault>

    Sunday, August 26, 2012 12:48 PM

All replies

  • At the very least you also need to add a customer.

    newEntity["customerid"] = new EntityReference("account", new Guid("509A5DCE-BD56-E111-9BBC-000C29336979"));
    

    Jason Lattimer

    Monday, August 27, 2012 2:31 AM