1. Create a new Workflow
- Customization > Scripting > Workflows > New
-Name the workflow
-Set the correct Record Type and Subtype(s) if applicable
-Set Event Definition to On Create and On Update
-Set Release Status to Released
-Save
2. Create a new field to store the initials
-Click on the New Field button
-Name the field "Initials"
-Set type to Free-Form Text
-Save
-Take note of the ID for the field. This will be used later.
3. Create a new state. Name it and save.
4. Create a new Set Field Value action to set the Initials field
-Click on the New Action button and select Set Field Value
-For the Field field select "Initials (Workflow)"
-For the Value select Formula. For the textarea enter this formula below. In this example {assigned} is the internal id of a field that contains an entity. See the article "How do I find a field's internal ID?" to get the internal ID of the field on the form that contains the entity:
regexp_replace({assigned},'(^| )([^ ])([^ ])*','\2.')To do this without periods use this formula:
regexp_replace({assigned},'(^| )([^ ])([^ ])*','\2')
-Save
5. Create an action to return an error if the field isn't set correctly
-Click the New Action button and select Return User Error
-For the Trigger on set it to either Before User Submit to have the error trigger when the record is saved or After Field Edit to have it trigger when specific fields are edited
-Set the Text to be the custom error message displayed. Eg "Field must start with customer's initials"
-For the conditions check that the field you want to start with the initials (Eg Project Name) equals "Initials (Workflow)" (located in the Field Value column of the Edit Workflow Conditions popup)
-Save conditions and Save the Action
Note: If entities have prefixes the regex in step 4 will need to be modified to ignore them. Example that stats at the 3rd character (ignores the first initial and the period. Try increase the number at the end of the formula if the prefix generates more initials):
SUBSTR(regexp_replace({assigned},'(^| )([^ ])([^ ])*','\2.'), 3)
Example without periods that starts on the second character:
SUBSTR(regexp_replace({assigned},'(^| )([^ ])([^ ])*','\.'), 2)
No comments:
Post a Comment