From ef6b9db4e39122ed8fd67f4ed52eb40793187d93 Mon Sep 17 00:00:00 2001 From: Cody Beaner Date: Wed, 21 Jun 2023 09:15:08 -0600 Subject: [PATCH] This will modify the associations on the key "StandardPriceBook" so that regardless of where it's used, it will use the correct pricebook, even if it was not part of your import. Additionally it will allow it in use cases where the StandardPriceBook was not being recognized before, such as in quotes and line items. --- src/commands/texei/data/import.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/commands/texei/data/import.ts b/src/commands/texei/data/import.ts index 772f395..02b30b1 100644 --- a/src/commands/texei/data/import.ts +++ b/src/commands/texei/data/import.ts @@ -145,9 +145,9 @@ export default class Import extends SfdxCommand { // If object is PricebookEntry, look for standard price book let standardPriceBookId = ''; - if (sobjectName === 'PricebookEntry') { + // if (sobjectName === 'PricebookEntry', ) { standardPriceBookId = ((await conn.query('Select Id from Pricebook2 where IsStandard = true')).records[0] as any).Id; - } + // } // Replace data to import with newly generated Record Type Ids for (const sobject of jsonData) { @@ -170,7 +170,8 @@ export default class Import extends SfdxCommand { for (const lookup of lookups) { // Regular lookups - if (sobject[lookup.name] && !(sobjectName === 'PricebookEntry' && sobject.Pricebook2Id === 'StandardPriceBook' && lookup.name === 'Pricebook2Id')) { + //if (sobject[lookup.name] && !(sobjectName === 'PricebookEntry' && sobject.Pricebook2Id === 'StandardPriceBook' && lookup.name === 'Pricebook2Id')) + if(sobject[lookup.name] && !(sobject.Pricebook2Id === 'StandardPriceBook' && lookup.name === 'Pricebook2Id')) { sobject[lookup.name] = recordIdsMap.get(sobject[lookup.name]); } @@ -288,7 +289,8 @@ export default class Import extends SfdxCommand { } // If object is PricebookEntry, use standard price book from target org - if (sobjectName === 'PricebookEntry' && sobject.Pricebook2Id === 'StandardPriceBook') { + //if (sobjectName === 'PricebookEntry' && sobject.Pricebook2Id === 'StandardPriceBook') { + if (sobject.Pricebook2Id === 'StandardPriceBook') { sobject.Pricebook2Id = standardPriceBookId; }