How to update worknote of Task after incident is created through record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2023 11:50 PM
Hi All,
I have record producer which contain one lookup select box variable on SC_TASK table so at the time of submission of request when user select TASK number then after submission of request it should update the WorkNote of selected task with created incident number. i.e. " Incident is raised for this issue"
Can anyone help me how I can configure this functionality.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 12:08 AM
Hi Yashvi,
You can write GlideRecord script to add comment on SC_TASK table on Record producer script field.
For refrence check below screenshot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 12:11 AM
Hi,
Please update record producer script field with below script, in place of Get("add variable value of your reference field")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 12:31 AM - edited 09-11-2023 04:58 PM
In the record producer script field you can access the select box variable, producer.variable_name, and call GlideRecord to get the task, add the incident number to the work notes and then update the task.
Example -
var grTask = new GlideRecord('task');
if (grTask.get(producer.task_number)) {
grTask.work_notes = current.number + ' has been created';
grTask.update();
}
The task number variable on the record producer should be a reference, this allows you to do a get() with the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 01:34 AM
Hi @YashviPatil,
You can try the below code
var gr = new GlideRecord('task');
gr.addQuery('number',producer.task_number.getDisplayValue()); // replace it with the correct variable name
gr.query();
if(gr.next()){
gr.comments.setJournalEntry(producer.task_number.getDisplayValue());
gr.update();
}
Mark this answer as correct and helpful if it solves your issue.
Regards,
Siva Jyothi M.