I'm looking to basically redact some information in our Salesforce environment, across various fields and using different REGEX patterns.
For example, in Case.Description, I have the following details:
CMP 40 Casual + Samsung A5 (Stock) username: jyi Email: [email protected] Password: Kjr username: 4nudf Email: [email protected] Password: Kjr2438 * Need setup
And the outcome I am hoping to get to is:
CMP 40 Casual + Samsung A5 (Stock) *Information redacted* *Information redacted* * Need setup
I've had a look at a similar question previously posted which has suggested using Apex instead of Flows to achieve this due to the Boolean nature of the REGEX function in Flows.
As I lack developer experience, I'm struggling to understand Apex basics to formulate a query.
Could someone help breakdown the steps required to perform the desired operation please? This is what I've gotten to so far, but am still stuck with multiple error messages:
- create new public apex class (to save for future reference) Checking that this is using Apex class and not Apex trigger (as per this article). The data already exists in saved records.
- how do I work with standard objects to access Case.Description field? Do I need to create a duplicated variable that is only visible in Apex?
- I want to be able to use the pattern.compile function to name various REGEX patterns and run them systematically.
- To use system.debug to first find the records to check the REGEX is correct, count the number of records that qualify and create a variable to quarantine those records.
- Run a secondary query to replace values (i.e. username, email, password) with new value (i.e. information redacted)
Thank you in advance for your help!!