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

PicklistEnabler errors out if picklist doesn't exist on target org #1414

Closed
cjbradshaw opened this issue Oct 2, 2023 · 4 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cjbradshaw
Copy link
Contributor

Describe the bug
When deploying or releasing, in the "Executing Pre Deployer Picklist Enabler" phase we get an error :
Unable to process Picklist update due to Cannot read properties of undefined (reading 'Metadata')
From what I see in a debug session, it errors out when trying to process the "picklistInOrg" variable
TypeError: Cannot read properties of undefined (reading 'Metadata')
at PicklistEnabler.execute (@dxatscale/sfpowerscripts.core/lib/package/deploymentCustomizers/PicklistEnabler.js:84:55)

To Reproduce
Add a new picklist field to an object. package and deploy.
During the Picklist Enabler processing, the getPicklistInOrg() returns undefined for the picklistInOrg variable
When it evalues
if (!picklistInOrg && picklistInOrg?.Metadata?.valueSetc?.valueSetDefinition) continue;
if doesn't continue, then falls over here
for (const value of picklistInOrg.Metadata.valueSet.valueSetDefinition.value)

Expected behavior
New picklists shouldn't need to be deployed as the bug this is trying to solve for is for modified picklists ?
so if you don't get a value back from the target org, skip further processing. It would also be helpful to get more information out of the trace logging too as theres a lot that can go wrong

Screenshots
If applicable, add screenshots to help explain your problem.

Platform Details (please complete the following information):

  • OS: MacOs
  • Version [e.g. CLI Version eg: 1.6.6] @dxatscale/sfpowerscripts/23.4.2 darwin-arm64 node-v20.5.1
  • Salesforce CLI(sfdx cli) Version: @salesforce/cli/2.7.11 darwin-arm64 node-v20.5.1
  • CI Platform: GtiHub

Additional context
Add any other context about the problem here.

@github-actions github-actions bot added the analysis To be decided on how to solution/fix label Oct 2, 2023
@azlam-abdulsalam
Copy link
Contributor

@Rocko1204 I haven't seen this one, can you hsve a look?

@eneag-sf
Copy link

eneag-sf commented Oct 3, 2023

Yes, I noticed the same during scratch org pool prepare (in an empty scratch org), while going through the logs. The deployment doesn’t stop/exit thought. It just says: Unable to process Picklist update due to Cannot read properties of undefined (reading 'Metadata') .
As you mention in the issue, it probably return undefined as this custom picklist doesn’t exist in an empty scratch org before the package is being installed.

@cjbradshaw
Copy link
Contributor Author

Running locally I change the line
if (!picklistInOrg && picklistInOrg?.Metadata?.valueSetc?.valueSetDefinition) continue;
to
if (!picklistInOrg || picklistInOrg?.Metadata?.valueSetc?.valueSetDefinition) continue;
which seemed to work

@azlam-abdulsalam
Copy link
Contributor

@cjbradshaw thanks for this one, its an incorrect conditional, what you meant was valueSetc should be changed to valueSet right.

@azlam-abdulsalam azlam-abdulsalam added bug Something isn't working and removed analysis To be decided on how to solution/fix labels Oct 13, 2023
@azlam-abdulsalam azlam-abdulsalam self-assigned this Oct 13, 2023
@azlam-abdulsalam azlam-abdulsalam added this to the October23 milestone Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants