Copying Goals Related List from Demand to Project with Create Project Script Include

Will_Allen
Tera Expert

Hello!

 

I was wanting to see if this is possible or not. We only have PPM module installed and there is a Goals related list on the demand form. When I look in the configure related list it shows Goal->Task. 

 

I have been tasked with the challenge of being able to copy all the goals that are in that related list to project when they click on create project script include. 

 

I have searched and searched and just cannot get my head around it. I can copy what is in the demand form to the project, but when it comes to related lists I don't know how. 

 

I have seen the links where it says the DemandToProjectCreationHelper should copy the goals but when we try creating a project, the goals related list in the project do not show the goals that were in the demand related list. 

 

I see that the goals related list associates it directly with Task=DMND0001106 for example. 

 

First question is it possible?

 

Second question, is this something that can be achieved with the DemandToProjectCreationHelper Script Include? 

 

Thank you. 

1 ACCEPTED SOLUTION

Will_Allen
Tera Expert

Wanted to just post an update in regards to this. After some testing, I sort of got it functioning minus one thing. 

When I select the create project link. It doesn't necessarily copy more so moves the related goal list from the demand to the project. I am needing to copy as to not remove the goals from the demand. 

 

Code Below: 

 

var rlgoal = new GlideRecord('goal'); //Indicating the table to query from
						rlgoal.addQuery("task", sys_id);
						rlgoal.query();

						while(rlgoal.next()){
							rlgoal.task = projId;
							rlgoal.sys_domain = projectDomain;
							rlgoal.setWorkflow(false);
							rlgoal.update();
							}

 

View solution in original post

2 REPLIES 2

Will_Allen
Tera Expert

Wanted to just post an update in regards to this. After some testing, I sort of got it functioning minus one thing. 

When I select the create project link. It doesn't necessarily copy more so moves the related goal list from the demand to the project. I am needing to copy as to not remove the goals from the demand. 

 

Code Below: 

 

var rlgoal = new GlideRecord('goal'); //Indicating the table to query from
						rlgoal.addQuery("task", sys_id);
						rlgoal.query();

						while(rlgoal.next()){
							rlgoal.task = projId;
							rlgoal.sys_domain = projectDomain;
							rlgoal.setWorkflow(false);
							rlgoal.update();
							}

 

I believe I have gotten it. Instead of .update(). You just need to use .insert().