Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Not possible to manipulate data in data packages prior to deployment #1196

Closed
petter-eikeland opened this issue Jan 16, 2023 · 1 comment
Closed
Assignees
Labels
enhancement enhancement to existing feature

Comments

@petter-eikeland
Copy link

petter-eikeland commented Jan 16, 2023

Describe the bug
Predeployment scripts do not overwrite csv files used for deployment of data packages.
Referencing the DX@Scale section regarding data packages , it should be possible to manipulate the csv files before upserting the data using SFDMU. However, sfpowerscripts utilizes the original values in the csv instead of the manipulated data resulting from the predeployment script

To Reproduce
Steps to reproduce the behavior:

  1. Create a new data package test-data-package to insert Product(2)s:

Product2.csv

Id,Name,IsActive
1,Replace,TRUE

export.json

{
    "objects": [
        {
            "query": "SELECT Id,Name,IsActive FROM Product2",
            "externalId": "Id",
            "operation": "Upsert"
        }
    ]
}
  1. Create a preDeployment script to manipulate the data and add the "preDeploymentScript" parameter in sfdx-project.json:
#!/bin/bash
sed -i "s/Replace/123/g" src/test-data-package/Product2.csv 	# Replace the "Replace" value with 123 - Linux syntax
cat src/test-data-package/Product2.csv  # Print content to ensure replacement was performed
sfdx sfdmu:run --path src/test-data-package -s csvfile -u $2 --noprompt --loglevel TRACE # Run SFDMU manually prior to data package deployment
  1. Add postDeployment script to sleep the Pull Request validation to avoid deletion of validation org before validating bug & add the "postDeploymentScript" parameter in sfdx-project.json:
#!/bin/bash
sleep 180  # sleep Pull Request in order to log in and verify data result
  1. Create a Pull Request of your changes

  2. When the data package is deployed in the Pull Request, authenticate towards the validation org using the sfdxAuthURL in PROD:
    SELECT SfdxAuthUrl__c FROM ScratchOrgInfo WHERE SignupUsername='USERNAME' &
    sfdx auth:sfdxurl:store -f auth.json

Expected behavior
Two Products with the name 123 are inserted in the validation org

Actual behavior
One Product with the name 123 is inserted with the manual SFDMU run. Another Product with the name Replace is inserted by the sfpowerscripts deployment of the test data package

Screenshots
Screenshot 2023-01-16 at 18 58 18

Platform Details (please complete the following information):

  • OS: Linux
  • Version: Ubuntu Latest
  • Salesforce CLI(sfdx cli) Version:
    • sfpowerscripts: latest (20.2.11)
    • sfdx: 7.179.0
    • sfdmu: 4.18.2
  • CI Platform: Azure DevOps

Additional context
Trying to insert Product Variations & Product Variation Parents as part of Salesforce Commerce Cloud. The Product Attribute Set record (& items) is represented as metadata, and thus cannot be inserted in the data package. Thus, to resolve the product data correctly, the Product Attribute Set Id needs to be queried and replaced prior to deployment of the data package

@github-actions github-actions bot added the analysis To be decided on how to solution/fix label Jan 16, 2023
azlam-abdulsalam pushed a commit that referenced this issue Jan 25, 2023
…yment scripts

Add additional parameters such as alias, workingDirectory and sourceDirectory to pre/post scripts

fix #1196
@azlam-abdulsalam azlam-abdulsalam added enhancement enhancement to existing feature and removed analysis To be decided on how to solution/fix labels Jan 25, 2023
@azlam-abdulsalam azlam-abdulsalam self-assigned this Jan 25, 2023
@azlam-abdulsalam
Copy link
Contributor

Added addtional params in Jan23 release

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement enhancement to existing feature
Projects
None yet
Development

No branches or pull requests

2 participants