- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi everyone,
I’m facing an issue with a Catalog Item in Employee Center. I have a form where users can schedule sessions and add participants using a Multi-Row Variable Set (MRVS).
The Workflow: When the form is initially submitted, an email is sent to all invited participants. This part works perfectly—no duplicates.
The Problem: When I open the Requested Item (RITM) later to add a new user to the session and save the record, the email notification is sent about 5 times to the user.
I am looking for a way to handle MRVS updates so that emails are only sent to the newly added row, or a way to prevent these duplicate triggers.
Has anyone encountered this? Should I be using a Business Rule with a specific condition, or is there a better way to compare the previous state of the MRVS with the new one?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello.
To trigger notifications only for new users added to the MVS from the created RITM, I can think of a couple of solutions. I'll share the one I think is best, the solution is basically to use a Business Rule to compare the previous MVS value with the new one and trigger notifications through an event.
- You have a catalog item, for example: Sessions cat item
- You have added a MVS to the catalog Item to add sessions and users, for example: Schedule Sessions
- User field is a referenced field to the sys_user table
- User field is a referenced field to the sys_user table
Here is where the solution starts:
- Create a new variable in the catalog Item: this field will store the current sessions
- Create a client script in the catalog item: this will copy the MVS value to the new variable (Current Sessions) as a serialized JSON
- Submit the catalog item
- The RITM should look like this
- Got to event registry module
- Click on new and fill the fields
- Create a business rule on the RITM table
- When to run
- Advanced:
- When to run
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
//getting MVS
try {
//Getting current sessions from the multiline text variable
var previosSessions = current.variables.current_sessions + "";
//Getting All sessions from the MVS variable
var currentSessions = current.variables.schedule_sessions + "";
//If they are differents it means a new session was added
if (previosSessions.length != currentSessions.length) {
//parsing the serialized JSONs to operate
previosSessions = JSON.parse(previosSessions);
currentSessions = JSON.parse(currentSessions);
//Trigger the event only for the new added users
for (var s = (previosSessions.length); s < currentSessions.length; s++) {
gs.eventQueue('new.session.email', current, currentSessions[s]["user"]);
}
current.variables.current_sessions = JSON.stringify(currentSessions);
}
} catch (e) {
gs.addErrorMessage(e);
}
})(current, previous);- Create a notification on the RITM table
- When to send
- Who will receive
- When to send
- Test the functionality
- Add one or more users to the MVS
- Save the record
- Go to emails log and verify emails were sent only to the new added users
- Add one or more users to the MVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello.
To trigger notifications only for new users added to the MVS from the created RITM, I can think of a couple of solutions. I'll share the one I think is best, the solution is basically to use a Business Rule to compare the previous MVS value with the new one and trigger notifications through an event.
- You have a catalog item, for example: Sessions cat item
- You have added a MVS to the catalog Item to add sessions and users, for example: Schedule Sessions
- User field is a referenced field to the sys_user table
- User field is a referenced field to the sys_user table
Here is where the solution starts:
- Create a new variable in the catalog Item: this field will store the current sessions
- Create a client script in the catalog item: this will copy the MVS value to the new variable (Current Sessions) as a serialized JSON
- Submit the catalog item
- The RITM should look like this
- Got to event registry module
- Click on new and fill the fields
- Create a business rule on the RITM table
- When to run
- Advanced:
- When to run
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
//getting MVS
try {
//Getting current sessions from the multiline text variable
var previosSessions = current.variables.current_sessions + "";
//Getting All sessions from the MVS variable
var currentSessions = current.variables.schedule_sessions + "";
//If they are differents it means a new session was added
if (previosSessions.length != currentSessions.length) {
//parsing the serialized JSONs to operate
previosSessions = JSON.parse(previosSessions);
currentSessions = JSON.parse(currentSessions);
//Trigger the event only for the new added users
for (var s = (previosSessions.length); s < currentSessions.length; s++) {
gs.eventQueue('new.session.email', current, currentSessions[s]["user"]);
}
current.variables.current_sessions = JSON.stringify(currentSessions);
}
} catch (e) {
gs.addErrorMessage(e);
}
})(current, previous);- Create a notification on the RITM table
- When to send
- Who will receive
- When to send
- Test the functionality
- Add one or more users to the MVS
- Save the record
- Go to emails log and verify emails were sent only to the new added users
- Add one or more users to the MVS
