locked
CRM 2011 - opportunity products add write in products RRS feed

  • Question

  • I'm trying to create a SOAP request to create a bunch of write in products for any give opportunity. 

    Below is my code.  It fails with this error: "object reference not set to an instance of an object"

    var oppid = new Guid("50CA4D23-6914-E111-9E02-782BCB2D6A7D");
    
          OpportunityProduct op = new OpportunityProduct();
          op.OpportunityId = new EntityReference("opportunity", oppid);
          op.IsProductOverridden = true;
          op.IsPriceOverridden = true;
          op.LineItemNumber = 1;    
          op.ProductDescription = "Arches";
          op.PricePerUnit.Value = 1;
          op.Quantity = 1;
          op.ExtendedAmount.Value = 0;
          op.Tax.Value = 0;      
          slos.Create(op);
    


    Monday, November 21, 2011 9:43 PM

Answers

  • it should look something like this

     

    // create a new write-in opportunity product with a manual discount applied

    OpportunityProduct writeInProduct =

    new

    OpportunityProduct

    {

    OpportunityId =

    new

    EntityReference(Opportunity.EntityLogicalName,

    _opportunityId),

    IsProductOverridden =

    true

    ,

    ProductDescription =

    "Example Write-in Product"

    ,

    PricePerUnit =

    new

    Money(20.00m),

    Quantity = 5,

    ManualDiscountAmount =

    new

    Money(10.50m),

    Tax =

    new

    Money(7.16m)

    };

    I don't know how you are creating a service or slos

    I hope this helps.


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Tuesday, November 22, 2011 12:50 AM
    • Marked as answer by FutureSteel Tuesday, November 22, 2011 3:36 PM
    Tuesday, November 22, 2011 12:50 AM

All replies

  • it should look something like this

     

    // create a new write-in opportunity product with a manual discount applied

    OpportunityProduct writeInProduct =

    new

    OpportunityProduct

    {

    OpportunityId =

    new

    EntityReference(Opportunity.EntityLogicalName,

    _opportunityId),

    IsProductOverridden =

    true

    ,

    ProductDescription =

    "Example Write-in Product"

    ,

    PricePerUnit =

    new

    Money(20.00m),

    Quantity = 5,

    ManualDiscountAmount =

    new

    Money(10.50m),

    Tax =

    new

    Money(7.16m)

    };

    I don't know how you are creating a service or slos

    I hope this helps.


    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Tuesday, November 22, 2011 12:50 AM
    • Marked as answer by FutureSteel Tuesday, November 22, 2011 3:36 PM
    Tuesday, November 22, 2011 12:50 AM
  • Perfect!  Thank you Amreek.
    Tuesday, November 22, 2011 3:36 PM