function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Naveed AnwarNaveed Anwar 

C# Error: STANDARD_PRICE_NOT_DEFINED

Hello,

 

I am running the following code in c# .net and getting the exception : STANDARD_PRICE_NOT_DEFINED

when trying to insert the pricebookentry record.

Can anyone tell, where to set the "STANDARD_PRICE". Thanks!

 

private string createPriceBookEntry(string priceBookId, string itemCode, string description, double unitPrice)

{

                string product2Id = createProduct2(itemCode, description);

                PricebookEntry pricebookEntry = new PricebookEntry();
                pricebookEntry.Pricebook2Id = priceBookId;
                
                pricebookEntry.UnitPrice = unitPrice;
                pricebookEntry.UnitPriceSpecified = true;
                pricebookEntry.IsActive = true;
                pricebookEntry.IsActiveSpecified = true;
                pricebookEntry.UseStandardPrice = false;
                pricebookEntry.UseStandardPriceSpecified = true;
                pricebookEntry.Product2Id = product2Id;
               
                SaveResult[] result = InsertToFF((sObject)pricebookEntry);
}

 

EDIT:

 

private SaveResult[] InsertToFF(sObject sfObj)
{
            SaveResult[] result = null;


            result =
                 ffInt.SFBinding.create(new sObject[] { sfObj });

            return result;
}

 

It worked fine with "Standard Price Book" but it generated error while creating opportunity line item:

Error was like: "The currency codes in Opportunity and Opportunity Line Item are not same"

 

I want to make it work for my own custom price book that has no standard Price field.

 

Thanks!