-
Notifications
You must be signed in to change notification settings - Fork 89
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
SALTO-3176 SALTO-7190 - salesforce - create dependencies based on formulas in metadata instances #7222
Conversation
…176-salesforce-formula-fields-in-some-types-are-saved-as-string-type
…176-salesforce-formula-fields-in-some-types-are-saved-as-string-type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a lot like formula_deps.ts
. Can they not be the same filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, "no" is an OK answer, just explain why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both filters at the bottom line parse formulas to create dependencies, but each works on different types of elements and therefore have different approach to how to get to the formula. in addition formulas in custom objects (parsed in formula_dpes) are formula types (have an inner field named formula and other fields), and formulas in metadata instances are just strings that their value happens to be a formula.
this is mainly why @tamtamirr and I decided to have a separate filter.
@tamtamirr also suggested to rename formula_deps to something like custom_object_formula_dependencies, so i will probably change it in the next round of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, let's do the rename (watch out for the adapter config though).
} | ||
|
||
const filter: FilterCreator = ({ config }) => ({ | ||
name: 'addFormulaDependencies', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would align the filter name with the file name.
const filter: FilterCreator = ({ config }) => ({ | ||
name: 'addFormulaDependencies', | ||
onFetch: ensureSafeFilterFetch({ | ||
warningMessage: 'Error while parsing formulas', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add that this is specifically in metadata instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I meant add this to the warning message.
warningMessage: 'Error while parsing formulas', | ||
config, | ||
fetchFilterFunc: async fetchedElements => { | ||
const instanceElements = fetchedElements.filter(isInstanceElement) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why define this? You can just fetchedElements.filter(isInstanceElement).forEach(...)
.
const config = { ...defaultFilterContext } | ||
filter = getFormulaDependencies({ config }) as FilterWith<'onFetch'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just:
const config = { ...defaultFilterContext } | |
filter = getFormulaDependencies({ config }) as FilterWith<'onFetch'> | |
filter = getFormulaDependencies({ config: defaultFilterContext }) as FilterWith<'onFetch'> |
[CORE_ANNOTATIONS.PARENT]: [customObjectTypeMock1], | ||
}, | ||
) | ||
const workFlowRule = createInstanceElement( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is one validationRuleInstance
and the other workFlowRule
? Be consistent.
[CORE_ANNOTATIONS.PARENT]: [customObjectTypeMock1], | ||
}, | ||
) | ||
const workFlowRule = createInstanceElement( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's "Workflow" the camel case here should be workflowRule
.
}) | ||
it('should add dependencies to the instances', async () => { | ||
await filter.onFetch([...instanceElements, ...types]) | ||
// eslint-disable-next-line no-underscore-dangle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of all of these eslint ignores, use instance.annotations[CORE_ANNOTATIONS.GENERATED_DEPENDENCIES]
.
…176-salesforce-formula-fields-in-some-types-are-saved-as-string-type
create dependencies based on formulas in metadata instances
_genereated_dependencies will be created for every metadata instance that contains a formula field, if the field's name is in the FORMULA_FIELDS constant.
Release Notes:
Salesforce:
User Notifications:
none