Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
This repository was 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

Description

@petter-eikeland

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

Activity

  1. added
    analysis
    on Jan 16, 2023
  2. added a commit that references this issue on Jan 25, 2023
    e242c7b
  3. added
    enhancement
    and removed
    analysis
    on Jan 25, 2023
  4. azlam-abdulsalam commented on Jan 25, 2023

    @azlam-abdulsalam
    Contributor

    Added addtional params in Jan23 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions