Record Producer: Creating new Project and Project task - Populating top_task

j0unss
Tera Expert

Hi,

I was asked to create new record producer which creates new Project [pm_project] and predifined Project Tasks [pm_project_task] under it. I'm now facing an issue that I'm unable to set top_task field correctly for created Project Task. Project Task should have Project as a top_task, but currently it populates project task itself as a top_task. 

My Record producer is set to Project table and latest version of my code is following, I have also tested to create Project Task first and setting top_task afterwards, but it didn't work either.

current.short_description = producer.short_description;
var project_id = current.getUniqueValue(); // Get Project sys_id

// Create new Project Task
var gr = new GlideRecord('pm_project_task');
gr.initialize();
gr.short_description = producer.short_description;
gr.parent = project_id;
gr.top_task = project_id;
gr.insert();


1 ACCEPTED SOLUTION

Hi @axa,

I did find a way which seems to be working without issues. Before I insert new record I set Workflow false, which did the trick.

var gr = new GlideRecord('pm_project_task');
gr.initialize();
gr.parent = project_id;
gr.top_task.setValue(gr.parent);
gr.short_description = producer.short_description
gr.description = producer.description;
gr.setWorkflow(false);
gr.insert();

-J0unss

View solution in original post

2 REPLIES 2

axa
Tera Contributor

Hi 

Did you find a solution for this as I am about to embark on something similar?

Hi @axa,

I did find a way which seems to be working without issues. Before I insert new record I set Workflow false, which did the trick.

var gr = new GlideRecord('pm_project_task');
gr.initialize();
gr.parent = project_id;
gr.top_task.setValue(gr.parent);
gr.short_description = producer.short_description
gr.description = producer.description;
gr.setWorkflow(false);
gr.insert();

-J0unss