0

When generating a .yml file with generate_dataset_mapping with cumulusci it resolves in following code(sample):

Insert Product2:
  sf_object: Product2
  table: Product2
  fields:
    Id: sf_id
    Name: Name
    IsActive: IsActive
    TestProd__c: TestProd__c
Insert Pricebook2:
  sf_object: Pricebook2
  table: Pricebook2
  fields:
    Id: sf_id
    Name: Name
    IsActive: IsActive
    TestPB__c: TestPB__c
Insert PricebookEntry:
  sf_object: PricebookEntry
  table: PricebookEntry
  fields:
    Id: sf_id
    IsActive: IsActive
    UnitPrice: UnitPrice
    UseStandardPrice: UseStandardPrice
    test1__c: test1__c
  lookups:
    Pricebook2Id:
      table: Pricebook2
    Product2Id:
      table: Product2

Extracting the data is no problem, but when loading the data (cci task run load_dataset) or using cci flow run qa_org --org qa (because of the customfields I created) the following error occures: STANDARD_PRICE_NOT_DEFINED:No standard price defined for this product:-- The reason for this error being is that the first few Insert opperations try to insert Pricebookentries for Products where there is no Standard Price configurated yet. When changing the order the same eror appears. I also tried so far:

Insert PricebookEntry:
  sf_object: PricebookEntry
  table: PricebookEntry
  fields:
    Id: sf_id
    IsActive: IsActive
    UnitPrice: UnitPrice
    UseStandardPrice: UseStandardPrice
    test1__c: test1__c
    **Pricebook2.IsStandard: IsStandard**
  lookups:
    Pricebook2Id:
      table: Pricebook2
    Product2Id:
      table: Product2
  **filters:**
    **- 'IsStandard = "true"'**

Here I want to update the Pricebook with all Products and create their standardprice. Sadly cci tries to fill in the field Pricebook2.IsStandard on the PricebookEntry but due to the fact that the field does not exists the process fails. When using fields instead of lookups for the pricebook2Id and the Product2Id it won´t work. As well as removing them won´t work because they are required. Long Story short: Is there a way to update the Pricebook instead of creating new ones and connecting them in the right manner?

2

Whitespace and indentation are significant in YAML. This mapping file isn't valid and would result in CumulusCI missing information and misunderstanding your intent.

A correctly-formatted version of your file (not tested, just formatted) would look like this:

Insert Pricebook2:
  sf_object: Pricebook2
  table: Pricebook2
  fields:
    Id: sf_id
    Name: Name
    IsActive: IsActive
    IsStandard: IsStandard
    External_ID__c: External_ID__c 
Insert PricebookEntry:
  sf_object: PricebookEntry
  table: PricebookEntry
  fields:
    Id: sf_id
    IsActive: IsActive
    UnitPrice: UnitPrice
    UseStandardPrice: UseStandardPrice
    ExternalID__c: ExternalID__c
  lookups:
    Pricebook2Id:
      table: Pricebook2
    Product2Id:
      table: Product2
      after: Product2
Insert Product2:
# etc.

You'll need to change your load order (by sequencing the steps in the file) as well to make the load successful. You cannot use an after: lookup to delay the population of a required lookup field, so you'll have to load Product2 before PricebookEntry and remove those after: clauses.

| improve this answer | |
  • Thanks for your suggestions. I removed the after clauses and changed the order but it still does not work. I tried by filtering the PricebookEntries by Pricebook2.IsStandard = True but it seems like I still get all PricebookEntries regardless of the status. tbh I´m not quite sure either were to append the filter function or if it makes any differences. – Ammar May 22 at 14:47
  • When working with the texei plugin for example it seems kind of easy. You just define two separate jsons, while the first one just holds all Records where Pricebook2.IsStandard = True the other one contains all Records where Pricebook2.IsStandard = False. Like they recommended on their blog. A Solution similar to that would be great – Ammar May 22 at 14:51
  • 1
    Our tooling (I'm on the CumulusCI team) does not work the same was as Texei's, although I believe it has similar or greater overall capabilities. How specifically is it not working at this point? – David Reed May 22 at 14:58
  • I totally agree to that. That´s why i want to use cumulus instead of texei. Right now i use the filtermethod like that: filters: - 'Pricebook2.IsStandard = True' on the PricebookEntry at the end of the Insert segment. But it still gets all Records regardless of the filter. My current order for the objects to load is: Pricebook,Product2,PricebookEntry – Ammar May 22 at 15:09
  • Without the filtermethod I get following error when loading the data to a new scratch org: REQUIRED_FIELD_MISSING:Required fields are missing: [Pricebook2Id, Product2Id]:Pricebook2Id Product2Id So I thought i could try something else with the filter – Ammar May 22 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.