CumulusCI icon indicating copy to clipboard operation
CumulusCI copied to clipboard

Error in task load_dataset - Standard_price_not_defined

Open tombvo opened this issue 4 years ago • 2 comments

Describe the bug

Hey, I'm trying to load testdata into a scratch org but i'm running into the following error: Error on record with id 66: STANDARD_PRICE_NOT_DEFINED: Before creating a custom price, create a standard price. ()

When inserting PricebookEntrys into Price books, you have to add them to the standard price book first, before you can add any to your custom price books. If I'm trying that with the load_dataset task, my sql inserts look like this:

`CREATE TABLE "PricebookEntry" (
	id INTEGER NOT NULL, 
	"IsActive" VARCHAR(255), 
	"UnitPrice" VARCHAR(255), 
	"Pricebook2Id" VARCHAR(255), 
	"Product2Id" VARCHAR(255), 
	PRIMARY KEY (id)
);

INSERT INTO "PricebookEntry" VALUES(35,'True','1000.0','3','25');
INSERT INTO "PricebookEntry" VALUES(36,'True','1000.0','3','13');
INSERT INTO "PricebookEntry" VALUES(37,'True','400.0','3','15');
INSERT INTO "PricebookEntry" VALUES(38,'True','1500.0','3','8');
INSERT INTO "PricebookEntry" VALUES(39,'True','500.0','3','17');
INSERT INTO "PricebookEntry" VALUES(40,'True','500.0','3','24');
INSERT INTO "PricebookEntry" VALUES(41,'True','700.0','3','16');
INSERT INTO "PricebookEntry" VALUES(42,'True','500.0','3','20');
INSERT INTO "PricebookEntry" VALUES(43,'True','600.0','3','11');
INSERT INTO "PricebookEntry" VALUES(44,'True','1000.0','3','18');
INSERT INTO "PricebookEntry" VALUES(45,'True','1000.0','3','4');
INSERT INTO "PricebookEntry" VALUES(46,'True','2500.0','3','19');
INSERT INTO "PricebookEntry" VALUES(47,'True','235.0','3','2');
INSERT INTO "PricebookEntry" VALUES(48,'True','250.0','3','12');
INSERT INTO "PricebookEntry" VALUES(49,'True','600.0','3','7');
INSERT INTO "PricebookEntry" VALUES(50,'True','200.0','3','5');
INSERT INTO "PricebookEntry" VALUES(51,'True','1500.0','3','26');
INSERT INTO "PricebookEntry" VALUES(52,'True','250.0','3','9');
INSERT INTO "PricebookEntry" VALUES(53,'True','100.0','3','22');
INSERT INTO "PricebookEntry" VALUES(54,'True','345.0','3','3');
INSERT INTO "PricebookEntry" VALUES(55,'True','400.0','3','6');
INSERT INTO "PricebookEntry" VALUES(56,'True','500.0','3','10');
INSERT INTO "PricebookEntry" VALUES(57,'True','50.0','3','27');
INSERT INTO "PricebookEntry" VALUES(58,'True','200.0','3','1');
INSERT INTO "PricebookEntry" VALUES(59,'True','2000.0','3','14');
INSERT INTO "PricebookEntry" VALUES(60,'True','250.0','3','23');
INSERT INTO "PricebookEntry" VALUES(61,'True','2000.0','3','21');
INSERT INTO "PricebookEntry" VALUES(62,'True','1000.0','5','13');
INSERT INTO "PricebookEntry" VALUES(63,'True','235.0','9','2');
INSERT INTO "PricebookEntry" VALUES(64,'True','1000.0','10','18');
INSERT INTO "PricebookEntry" VALUES(65,'True','250.0','2','9');
INSERT INTO "PricebookEntry" VALUES(66,'True','400.0','1','15');
INSERT INTO "PricebookEntry" VALUES(67,'True','1500.0','7','26');
INSERT INTO "PricebookEntry" VALUES(68,'True','1000.0','6','4');
INSERT INTO "PricebookEntry" VALUES(69,'True','600.0','4','7');
INSERT INTO "PricebookEntry" VALUES(70,'True','100.0','8','22');`

As you can see, the inserts until id 62 reference to Pricebook2Id '3' (which is the standard price book), afterwards my custom pricebooks are used. My guess is that cci does not add them line by line and therefore, no entries on the standard price book exist, which breaks the task.

Is there any solution to this or is it possible to divide the sql file into more files?

Reproduction steps

  1. Manually add products, pricebooks and pricebookentrys
  2. Generate a mapping.yml with that Inserts "Product2" and "Pricebook2"
  3. Insert PricebookEntrys and and use "Pricebook2Id" and "Product2" as lookups
  4. Extract dataset
  5. load_dataset into scratch org

Your CumulusCI and Python versions

CumulusCI version: 3.47.0 Python version: 3.9.0

Operating System

Windows 11

Windows environment

PowerShell

CumulusCI installation method

pipx

Error Gist

No response

Additional information

No response

tombvo avatar Nov 01 '21 16:11 tombvo

@tombvo I am not especially familiar with Pricebooks. It sounds like the correct mode of data loading is to sequence the load of PricebookEntries so that those associated with the standard pricebook are all completed before loading of PricebookEntries against custom pricebooks begins. Is that accurate?

How is the standard pricebook identified?

davidmreed avatar Nov 09 '21 15:11 davidmreed

I am not especially familiar with Pricebooks. It sounds like the correct mode of data loading is to sequence the load of PricebookEntries so that those associated with the standard pricebook are all completed before loading of PricebookEntries against custom pricebooks begins. Is that accurate?

That is correct, we have already tried to workaround it by using COMMIT; below the PricebookEntrys which are inserted to the standard pricebook, but nothing has worked out so far. I think it's actually really interesting, that the sql inserts are ordered the way that the entries for the standard price book are listed first, so that was taken into account somewhere - it's just needs to be sequenced which is probably not happening right now.

I'm not sure what you mean by identified but if you're refering to the mapping.yml - it looks like this:

Insert Pricebook2:
  sf_object: Pricebook2
  fields:
    - IsActive
    - Name

tombvo avatar Nov 11 '21 13:11 tombvo