Email template trigger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 04:57 AM
Hi,
When the state changes to Work in progress email template should populated in workspace email tab such that if there are particular mandatory fields not filled template with those field names should be populated and the state should go to new .
If mandatory fields are having data then state should be on hold.
how can we achieve it?
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 06:06 AM
I would propose:
1. Create a Business Rule
2. Check Mandatory Fields and Trigger Logic
Inside the script of the business rule:
(function executeRule(current, previous /*null when async*/) {
var missingFields = [];
// Check mandatory fields (example of a list of values)
if (!current.short_description) {
missingFields.push("Short Description");
}
if (!current.category) {
missingFields.push("Category");
}
if (!current.assignment_group) {
missingFields.push("Assignment Group");
}
if (missingFields.length > 0) {
// Populate a custom field or log with missing fields
var message = "The following mandatory fields are missing: \n" + missingFields.join('\n');
// Use a field to carry this info to Workspace Email tab
current.u_email_template_message = message;
// Revert state to "New"
current.state = 1; // or 'New' state value
gs.addInfoMessage("Mandatory fields missing. Returning to New state.");
} else {
// All fields filled: move to On Hold
current.state = 3; // or 'On Hold' state value
}
})(current, previous);
3. Populate the Email Tab in Workspace
To show the generated message in the Workspace Email Tab:
Ensure u_email_template_message or similar is a field displayed in the email composer.
Use a UI Policy or Client Script (in Workspace context) to automatically copy this field’s content into the email body if present.
Or use a Custom Email Template + script to prefill the email body when a condition is met (e.g., state is “New” and u_email_template_message is not empty).
Use Flow Designer (optional alternative)
If you prefer Flow Designer:
Create a Flow triggered on record update (state changes to Work in Progress).
Add logic using Script step to check fields.
Use Action step to send an email or populate a field.
Update the state accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 06:10 AM
1. Identify the Table and Fields
Make sure you know:
The table you're working with (e.g., incident, change_request, custom table).
Which fields are mandatory (e.g., assignment_group, short_description).
2. Use a Business Rule (BR)
Create a Before Business Rule on the relevant table.
Example: Business Rule Configuration
Name: Validate Mandatory Fields on WIP
Table: Your table (e.g., incident)
When: Before
Update: True
Condition:
current.state.changesTo('Work in Progress')
3. Script Logic Inside BR
(function executeRule(current, previous /*null when async*/) {
var missingFields = [];
// Check required fields
if (!current.short_description) {
missingFields.push("Short Description");
}
if (!current.assignment_group) {
missingFields.push("Assignment Group");
}
// If any fields are missing
if (missingFields.length > 0) {
// Prepare message (email body)
var body = "The following mandatory fields are missing:\n\n";
body += missingFields.join("\n");
// Optionally store this in a field that shows in Workspace Email Tab
current.work_notes = body;
// Change state back to New
current.state = 1; // 1 = New
} else {
// All mandatory fields are filled
current.state = 3; // 3 = On Hold (adjust as needed)
}
})(current, previous);
4. Optional – Trigger Email Template in Workspace
If you're using Agent Workspace, and want this message to auto-populate in the Email Tab:
Use UI Actions or Compose Email Scripts to pre-fill body when accessed.
Alternatively, if you store the message in a field like email_description or a journal field, agents can easily copy/paste.