Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error adding picklist value #479

Closed
Raptor399 opened this issue Jan 17, 2022 · 6 comments · Fixed by #480
Closed

Error adding picklist value #479

Raptor399 opened this issue Jan 17, 2022 · 6 comments · Fixed by #480
Labels

Comments

@Raptor399
Copy link

Raptor399 commented Jan 17, 2022

I am trying to add a picklist value and get the following error message:

ERROR running browserforce:apply:  The "url" argument must be of type string. Received undefined

I don't understand which "url" argument the error message is talking about, or what I can do to prevent the problem.

To reproduce, use the following files:

sfdx-project.json

{
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "52.0"
}

config/project-scratch-def.json

{
  "country": "US",
  "edition": "Developer",
  "settings": {
    "lightningExperienceSettings": {
      "enableS1DesktopEnabled": true
    }
  },
  "orgName": "Test",
  "adminEmail": "test@test.com"
}

config/project-scratch-browserforce.json

{
    "$schema": "https://raw.githubusercontent.com/amtrack/sfdx-browserforce-plugin/master/src/plugins/schema.json",
    "settings": {
        "security": {
            "loginAccessPolicies": {
                "administratorsCanLogInAsAnyUser": true
            }
        },
        "picklists": {
            "picklistValues": [{
                    "metadataType": "StandardValueSet",
                    "metadataFullName": "ForecastCategoryName",
                    "value": "Most Likely",
                    "newValue": "Most Likely",
                    "active": true
                }
            ]
        }
    }
}

With these files, run the following commands:

$ sfdx force:org:create -s -a scratch -f config/project-scratch-def.json --wait 10
(node:11429) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Successfully created scratch org: 00D1j000000EP2uECG, username: test-p0krdduvd2tc@example.com
$ sfdx force:config:set defaultusername=scratch
=== Set Config
Name             Value    Success
───────────────  ───────  ───────
defaultusername  scratch  true
$ sfdx browserforce:apply -f config/project-scratch-browserforce.json --targetusername scratch
logging in... done
Applying definition file config/project-scratch-browserforce.json to org test-p0krdduvd2tc@example.com
[Security] retrieving state... done
[Security] no action necessary
[Picklists] retrieving state... failed
ERROR running browserforce:apply:  The "url" argument must be of type string. Received undefined
logging out... done
$ 

Notice how the security action seems to run fine, whereas the picklist action doesn't.

@github-actions
Copy link

🎉 This issue has been resolved in version 2.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@amtrack
Copy link
Owner

amtrack commented Jan 18, 2022

@Raptor399 Thanks for you report!

I wasn't aware of the StandardValueSet ForecastCategoryName and so there was no mapping entry yet.
I've now added one in the latest release.

Please note that you'll have to provide statusCategory (instead of value):

        {
          "metadataType": "StandardValueSet",
          "metadataFullName": "ForecastCategoryName",
          "newValue": "Most Likely",
          "statusCategory": "Most Likely",
          "active": true
        }

P.S.: Unfortunately it's difficult to keep track of available StandardValueSets.
If you know some other resource/API to list all available StandardValueSets, please let me know.
I'm only aware of https://developer.salesforce.com/docs/atlas.en-us.234.0.api_meta.meta/api_meta/standardvalueset_names.htm where ForecastCategoryName is not listed.

@Raptor399
Copy link
Author

Thank you for the update and the correction, @amtrack !

I'm getting an error when trying to apply the modified project-scratch-browserforce.json to a new test org, though? This is what I get:

$ sfdx plugins       
sfdx-browserforce-plugin 2.8.0
$ sfdx browserforce:apply -f config/project-scratch-browserforce.json --targetusername scratch

logging in... done
Applying definition file config/project-scratch-browserforce.json to org test-cmuq29hktfni@example.com
[Security] retrieving state... done
[Security] no action necessary
[Picklists] retrieving state... done
[Picklists] changing 'picklistValues' to '[{"metadataType":"StandardValueSet","metadataFullName":"ForecastCategoryName","newValue":"Most Likely","statusCategory":"Most Likely","active":true}]'... failed
ERROR running browserforce:apply:  waiting for XPath `//tr[td[2][text() = "undefined"]]//td[1]//a[contains(@href, "/setup/ui/picklist_masteractivate.jsp")]` failed: timeout 30000ms exceeded
logging out... done

@amtrack
Copy link
Owner

amtrack commented Mar 5, 2022

@Raptor399 OK, I'm able to reproduce this. Will look into it.

@amtrack amtrack reopened this Mar 5, 2022
@amtrack
Copy link
Owner

amtrack commented Mar 5, 2022

@Raptor399 Sorry for the wrong config I provided last time! The active property should be omitted.
When adding a new picklist palue, it is set active by default. So there is no need to provide the active property.
The code actually interprets a given active property as instruction to enable/disable an existing picklist value.

I've tried the following config, and it seems to work now:

config/project-scratch-browserforce.json:

{
  "$schema": "https://raw.githubusercontent.com/amtrack/sfdx-browserforce-plugin/master/src/plugins/schema.json",
  "settings": {
    "security": {
      "loginAccessPolicies": {
        "administratorsCanLogInAsAnyUser": true
      }
    },
    "picklists": {
      "picklistValues": [
        {
          "metadataType": "StandardValueSet",
          "metadataFullName": "ForecastCategoryName",
          "newValue": "Most Likely",
          "statusCategory": "Most Likely"
        }
      ]
    }
  }
}
$ sfdx browserforce:apply -f config/project-scratch-browserforce.json
logging in... done
Applying definition file config/project-scratch-browserforce.json to org test-3akzhbwfgno5@example.com
[Security] retrieving state... done
[Security] no action necessary
[Picklists] retrieving state... done
[Picklists] changing 'picklistValues' to '[{"metadataType":"StandardValueSet","metadataFullName":"ForecastCategoryName","statusCategory":"Most Likely","newValue":"Most Likely"}]'... done
logging out... done

$ sfdx browserforce:apply -f config/project-scratch-browserforce.json
logging in... done
Applying definition file config/project-scratch-browserforce.json to org test-3akzhbwfgno5@example.com
[Security] retrieving state... done
[Security] changing 'loginAccessPolicies' to '{"administratorsCanLogInAsAnyUser":true}'... done
[Picklists] retrieving state... done
[Picklists] no action necessary
logging out... done

@amtrack amtrack closed this as completed Mar 5, 2022
@Raptor399
Copy link
Author

Excellent! Can confirm this works on my end as well. Thank you for investigating!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants