The CreatorCon Call for Content is officially open! Get started here.

Creating Problem Tasks Automatically

KeithM2
Kilo Contributor

I'm currently working in the Aspen release of SN and I'm trying to automatically create 2 tasks when a new problem is submitted. I've tried using a workflow but that didn't work. I tried an onSubmit client script and that doesn't seem to be working either. Below is the client script I setup:


function onSubmit() {
//This script creates 2 new problem tasks
var newtask1 = new GlideRecord('task');
newtask1.initialize();
newtask1.short_description = 'Create Root Cause Analysis (RCA)';
newtask1.assigned_group = 'Problem Mgmt';
newtask1.assigned_to = '1. Queue Coordinator';
newtask1.insert();

var newtask2 = new GlideRecord('task');
newtask2.initialize();
newtask2.short_description = 'Create Problem and Resolution Plan';
newtask2.assigned_group = 'Problem Mgmt';
newtask2.assigned_to = '1. Queue Coordinator';
newtask2.insert();
}

Thanks to all who have suggestions.

8 REPLIES 8

TJW2
Mega Guru

A WF should be your answer. Attach the workflow when the problem is created.

Or you could use a BR on Insert to create the tasks,


morgang
Giga Expert

Looks like the problem record should referenced each task; my guess would be the tasks are probably getting created, just not associated to your problem.

Something like this might work? (In Demo13 problem workflow at the moment - not sure if on Aspen they're just tasks instead of problem tasks.)



function makeProblemTasks()
{
var newtask1 = new GlideRecord('problem_task');
newtask1.initialize();
newtask1.parent = current.sys_id;
newtask1.problem = current.sys_id;
newtask1.short_description = 'Create Root Cause Analysis (RCA)';
newtask1.assigned_group = 'Problem Mgmt';
newtask1.assigned_to = '1. Queue Coordinator';
newtask1.insert();

var newtask2 = new GlideRecord('problem_task');
newtask2.initialize();
newtask2.parent = current.sys_id;
newtask2.problem = current.sys_id;
newtask2.short_description = 'Create Problem and Resolution Plan';
newtask2.assigned_group = 'Problem Mgmt';
newtask2.assigned_to = '1. Queue Coordinator';
newtask2.insert();
gs.addInfoMessage("Built new tasks, "+newtask1.number+' and '+newtask2.number);
} makeProblemTasks();




KeithM2
Kilo Contributor

Morgan, what you sent was it. Based on everyone's input and this last post from you, that fixed it! Your script was spot-on! Thank you everyone!!


HarshTimes
Tera Guru

first thing, client script does not support insert,update ans delete glide operation.You have to write a before insert or after insert business rule.

Thanks
Harsh