- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2019 04:50 PM
Hello Experts,
I have created a survey for Service Desk team. One of the question in the Survey is as below
Whenever the response is Yes, I want to create an actionable Task to the Service Desk managers , they get notified and can update & close the task . I am looking for some guidance what would be the best approach to do this ?
Thx
ram.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2019 12:18 AM
ram,
Create an 'After' Business Rule on the [asmt_assessment_instance] table that runs when a record is updated. The condition should be as follows:
State | Changes to | Complete
You only want this BR to run when the user has completed the survey and has therefore populated the field you require to drive task creation. This table holds the survey state and should update the record when a survey is completed.
You'll need the sys_id of the 'current' record to query the [asmt_metric_result] table. This table holds not only the numeric value of the user's input but also the semantic (text) value of the input.
Since you know the specific question that drives task creation, you can hard-code this value. And since there are only two answers to this question, you can create an 'if' statement with the answer you're looking for.
(function executeRule(current, previous /*null when async*/ ) {
var metrics = new GlideRecord('asmt_metric_result');
metrics.addQuery('instance', current.sys_id);
//hard-code the 'Metric' field value since this will not change
//this value is the 'name' of the survey question so it should be unique
metrics.addQuery('metric', '44934f181bc8805420748622dd4bcbbf');
metrics.query();
//returns one record since survey question names are unique
if (!metrics.nil()) {
var input = metrics.string_value;//value is 'yes' or 'no' depending on user input
if (input == 'yes') {
//fire event to trigger your notification
//change the last two arguments to fit your requirements
gs.eventQueue('my.registered.event', current, gs.getUserID(), gs.getUserName());
}
}
})(current, previous);
The above code does not include the task creation but that's easy enough to script. Just use the initialize() & insert() functions to create and save the new record and the setValue() function to set the task record values like the 'assigned_to' field. Register your event and configure your notification to have it fire when the event is triggered.
Hope this helped!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Can I implement flow design for this. Instead of BR rule
