How to generate an additional comment in a Task through workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 11:47 AM
Good afternoon, everyone.
I'm working on a workflow related to the creation of Catalog Tasks in a specific Catalog Item and I need to write a Script that would generate additional comments in each task, as the evolving on the RITM work.
Could you please help me on this? Also need to know how to catch the REQnumber related (maybe through a GlideRecord)
Please find attached a screenshot of the current workflow and one of its scripts:
function updateAdditionalComments() {
var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery('active=true^request_item=' + current.getValue('sys_id'));
grTask.orderBy('sys_updated_on');
grTask.setLimit(1);
grTask.query();
while (grTask.next()) {
var msg = "";
msg = "Olá, aqui se inicia o processo de homologação de software, algumas informações importantes:" +
"\n- Para acompanhamento do processo, utilize o É Comigo Tecnologia, toda a comunicação será feita através do chamado" + [REQnumber]
"\n- Fique atento em seu e-mail, o ServiceNow dispara um e-mail para sua caixa de entrada a cada atualização no chamado" + [REQnumber]
"\n- O processo tem um SLA total de até 30 dias para ser finalizado" +
"\n" +
"\n A tarefa " + grTask.number.getDisplayValue() + " foi criada e agora está em análise técnica e funcional o Gestor Técnico apontado no formulário";
grTask.comments = msg;
grTask.update();
}
}
updateAdditionalComments();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 06:55 PM
you are running that script even before creating those tasks
you should be having that script in the advanced script section in each of those Catalog Tasks activities
Something like this in each catalog task advanced script
var msg = "";
msg = "Olá, aqui se inicia o processo de homologação de software, algumas informações importantes:" +
"\n- Para acompanhamento do processo, utilize o É Comigo Tecnologia, toda a comunicação será feita através do chamado" + current.request.getDisplayValue()
"\n- Fique atento em seu e-mail, o ServiceNow dispara um e-mail para sua caixa de entrada a cada atualização no chamado" + current.request.getDisplayValue()
"\n- O processo tem um SLA total de até 30 dias para ser finalizado" +
"\n" + current.request.getDisplayValue()
"\n A tarefa " + task.number + " foi criada e agora está em análise técnica e funcional o Gestor Técnico apontado no formulário";
task.comments = msg;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 06:56 PM
if you face any challenge in getting catalog task number then check this link
How to access the catalog task number within the Workflow Activity creating the task?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 08:01 PM
you can also use before insert BR on sc_task with below condition
current.request_item.cat_item.name == 'Your Catalog Item Name Here'
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var msg = "";
msg = "Olá, aqui se inicia o processo de homologação de software, algumas informações importantes:" +
"\n- Para acompanhamento do processo, utilize o É Comigo Tecnologia, toda a comunicação será feita através do chamado" + current.request.getDisplayValue()
"\n- Fique atento em seu e-mail, o ServiceNow dispara um e-mail para sua caixa de entrada a cada atualização no chamado" + current.request.getDisplayValue()
"\n- O processo tem um SLA total de até 30 dias para ser finalizado" +
"\n" + current.request.getDisplayValue()
"\n A tarefa " + current.number + " foi criada e agora está em análise técnica e funcional o Gestor Técnico apontado no formulário";
current.comments = msg;
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 10:15 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader