sfdx-hardis icon indicating copy to clipboard operation
sfdx-hardis copied to clipboard

[linter] detect all fields not included in the sfdx project but referenced in at least one email template

Open mickaelgudin opened this issue 1 year ago • 4 comments

Deployment behaviour We can deploy email templates to a target org without needing to deploy fields that are referenced in these email templates.

The linter feature in a nutsheel The idea is to provide a linter feature that allow us to see what fields are not in the sfdx project but are in one of the email templates of the sfdx project.

Example of how fields are referenced in an email template

Dear {!Contact.FirstName},

Thank you for your interest in our product. We are pleased to provide you with the following information:

Account Name: {!Account.Name}
Custom Field Value: {!Custom_Object__c.MyCustomField__c}

If you have any questions or need further assistance, please feel free to contact us.

mickaelgudin avatar May 17 '23 15:05 mickaelgudin

@mickaelgudin good idea :)

What is the behaviour in case a email template contains a ref to a field that is not existing ? Is the deployment failing ? Or does it passes then when the email template is used there is an error ?

nvuillam avatar May 17 '23 17:05 nvuillam

@nvuillam based on the above example the email template would be deployed regardless of whether or not the field Custom_Object__c.MyCustomField__c exist (even if it's a cross object formula there is no check of each fields that are contained in the email template body during deploying).

mickaelgudin avatar May 17 '23 19:05 mickaelgudin

So there is a clear use case :)

Would you like to build the command hardis:lint:emailtemplates ? :)

nvuillam avatar May 17 '23 20:05 nvuillam

No, I'll just leave the idea here since I noticed this behavior on a project.

I think the command hardis:lint:access can be reused specially the part where custom fields are retrieved and based on this we just need to iterate over all email templates and store all field references {!SObject.CustomField__c} and filter to keep only those who are not in the project.

mickaelgudin avatar May 18 '23 11:05 mickaelgudin