texei / texei-sfdx-plugin

Texeï's plugin for sfdx
https://texei.github.io/texei-sfdx-plugin/
BSD 3-Clause "New" or "Revised" License
122 stars 37 forks source link

cpq settings fails to update Groups config #164

Closed nabondance closed 4 months ago

nabondance commented 6 months ago

command: sf texei cpqsettings set When specifying a key-value that is a picklist depending on another value in the Group tab, the script timeout.

Steps to reproduce:

  1. Have cpq installed

  2. Have cpq package configured with everything on "Groups" set as false

    image
  3. Have the configuration input file:

    {
    "Groups": {
        "Solution Groups Enabled": true,
        "Require Group Name": true,
        "Object": "SBQQ__SolutionGroup__c",
        "Name Field": "Group Name",
        "Description Field": "Description"
    }
    }
  4. Do the command sf texei cpqsettings set --inputfile=<your input file path>

  5. Have the error:

Logging in to instance https://XXXXXXX.scratch.my.salesforce.com Navigating to CPQ Settings Page https://XXXXXXX--sbqq.visualforce.com/apex/EditSettings Switching to tab Groups Looking for 'Solution Groups Enabled'... Checkbox Value updated from false to true Looking for 'Require Group Name'... Checkbox Value updated from false to true Looking for 'Object'... Text Value updated from to SBQQSolutionGroupc Looking for 'Name Field'... Error Error (1): Waiting for selector //option[text()='Group Name'] failed: Waiting failed: 30000ms exceeded

It is working in 2.2.1 It is failing in 2.4.1 and 2.5.0

My finding so far:

nabondance commented 6 months ago

I checked a bit more Breaking since 2.2.2, probably this PR: https://github.com/texei/texei-sfdx-plugin/pull/146

nabondance commented 5 months ago

Hi @w-andre , I saw you're the one who made the PR #146 Did you had this issue or a similar one since 2.2.2 ?

nabondance commented 5 months ago

After a deeper investigation, there is more details on the issue:

As of today, the issue only concern two settings in the Groups tab:

Root cause of the issue: Theses fields are picklist fields with values depending on another setting (Object), the picklist values options are calculated by Salesforce. In the code, to select a picklist value we wait for the picklist to exist (with waitForSelector) which is great but it doesn't wait the picklist to have actual values and not only --None--. So when we want to select the specified value, the script fails because the value doesn't exist on the picklist.

Possible solutions:

  1. Add a await page.waitForTimeout(1000); only for the 2 concerned settings
  2. Improve the waitFor Selector to wait until there is values different then --None--
  3. Improve the waitFor Selector to wait until there is the value to select

Personal feedback: Adding the waitForTimeout is ugly but it works. I couldn't make the other options working, maybe a real js/ts dev can do it better then I.

What's your thoughts on that @FabienTaillon ?

nabondance commented 5 months ago

update, the issue also exist for Subscriptions and Renewals tab:

w-andre commented 5 months ago

Hi @nabondance,

I've looked into this issue and can reproduce it on my side.

The select input is stored in a variable and all further processing relies on this variable. The problem is that the asynchronously loaded options are not populated in this object and therefore we run into a timeout because the values will never be available for us. I've made a code change that should fix the issue and will create a PR containing it. Maybe you could check if it works for you too.

nabondance commented 5 months ago

Hi @w-andre,

Thank you for understanding the issue better than I. The explanation is very clear, I understand it now.

I checked the PR and it fix the issue on our side too.

w-andre commented 5 months ago

@nabondance Great to hear the fix works for you too!

This isn't really the right place for this, but anyways: Do you have any experience in source tracking Salesforce Billing settings? At the moment we are only tracking our CPQ settings in a git repo with the ability to deploy them. Our Billing settings are only screenshots for now. I would be thankful if you have anything to share in this regard. 😄

nabondance commented 5 months ago

Hi @w-andre ,

Billing package config is in fact easier to manage than cpq package config because it uses object we have read/write rights on: blng__BillingConfig__c Basically it is simply managing config data and you can do it with any classic way to manage data:

If you wants to go even deeper on managing data, in my Github profile there's slides/video of a presentation I made about it

w-andre commented 5 months ago

Hi @nabondance, I didn't know about the custom setting blng__BillingConfig__c. That was the missing piece for me! Thanks! 😄