How to copy Demand fields to Project fields

Michael Bachme1
Kilo Guru

When a Project is created from a Demand, how do I copy the Business Case field on the Demand table to the Description field on the Project table?

So far I've copied the Demand Business Rule, "Create Strategic Type on Approve" and added the bolded line but it doesn't seem to work:

function createNewProject(){

  var project = new GlideRecord("pm_project");

  project.initialize();

  project.setValue("short_description", current.short_description);

  project.setValue("description", current.business_case); //copy DMND business case to PRJ description

  project.setValue("parent", current.sys_id);

Thoughts?

27 REPLIES 27

Michael Fry1
Kilo Patron

There is a Create Project UI action that is available on the demand table after demand is approved, did you check that out?


Yes, but it only copies the short description.


Can you add the one more line next to short description in script Include which UI action call to update Project fields.



project.setValue("description", demand.getValue('business_case'));



Thanks,


Bharath.


It doesn't work.



function createNewProject(){


  var project = new GlideRecord("pm_project");


  project.initialize();


  project.setValue("short_description", current.short_description);


  project.setValue("description", current.business_case);


  project.setValue("description", demand.getValue('business_case'));


  project.setValue("parent", current.sys_id);


  var projId = project.insert();


  if(JSUtil.nil(current.related_records))


  current.related_records = projId;


  else


  current.related_records = current.related_records + "," + projId;


  current.project = projId;


  gs.addInfoMessage(gs.getMessage('Project {0} has been created.', project.number));


  return project;


}