Skip to content

Commit

Permalink
Include All Keys in standardValue XML for add_standard_value_set_entr…
Browse files Browse the repository at this point in the history
…ies Task from Entries Option with Backward Compatibility (#3820)

```
  task: add_standard_value_set_entries
  options:
      api_names: CaseOrigin
      entries:
          - fullName: New Account
            label: New Account
          - fullName: Questionable Contact
            label: Questionable Contact
      ui_options:
          name: Add values to Case Origin picklist
```

For the add_standard_value_set_entries task, we noticed that only the
fullname and label keys were being considered when generating the XML
file for deployment, while other keys were being ignored. We've
implemented a fix to ensure that all provided keys are now included in
the standard value entry XML file.

For example ,

If the entries were given like this , 
```
entries:
   - fullName: testerunner
      label: testrunner
      groupingString: Scheduled
```     
Now, it generates an XML like this 
```
<standardValue>
    <fullName>testerunner</fullName>
    <label>testrunner</label>
    <default>false</default>
    <groupingString>Scheduled</groupingString>
</standardValue>
```

But, there were case by case scenarios added for
"OpportunityStage","CaseStatus","LeadStatus" which were left untouched
to maintain backward compatibility and default will be always set as
False, even though we pass in the entries as true.

Related work item :
[W-16541459](https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00001zQu1TYAS/view)
  • Loading branch information
lakshmi2506 authored Aug 22, 2024
1 parent 1210f09 commit 1dece6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cumulusci/tasks/metadata_etl/tests/test_value_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_adds_entry(self):
"api_version": "47.0",
"api_names": "bar,foo",
"entries": [
{"fullName": "Test", "label": "Label"},
{"fullName": "Test_2", "label": "Label 2"},
{"fullName": "Test", "label": "Label", "group": "Schedule"},
{"fullName": "Test_2", "label": "Label 2", "default": "true"},
],
},
)
Expand All @@ -57,6 +57,9 @@ def test_adds_entry(self):
assert len(entry) == 1
label = entry[0].findall(f".//{MD}label")
assert len(label) == 1
group = entry[0].findall(f".//{MD}group")
assert group[0].text == "Schedule"
assert len(group) == 1
assert label[0].text == "Label"
default = entry[0].findall(f".//{MD}default")
assert len(default) == 1
Expand Down
12 changes: 8 additions & 4 deletions cumulusci/tasks/metadata_etl/value_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,19 @@ def _transform_entity(self, metadata: MetadataElement, api_name: str):

elem.append("default", text="false")

if api_name in ["OpportunityStage", "CaseStatus"]:
if api_name == "CaseStatus":
elem.append("closed", str(entry["closed"]).lower())

if api_name == "OpportunityStage":
elif api_name == "OpportunityStage":
elem.append("won", str(entry["won"]).lower())
elem.append("closed", str(entry["closed"]).lower())
elem.append("probability", str(entry["probability"]))
elem.append("forecastCategory", entry["forecastCategory"])

if api_name == "LeadStatus":
elif api_name == "LeadStatus":
elem.append("converted", str(entry["converted"]).lower())

else:
for entry_key in entry:
if entry_key not in ["fullName", "label", "default"]:
elem.append(entry_key, str(entry[entry_key]))
return metadata

0 comments on commit 1dece6c

Please sign in to comment.