The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Is it possible to copy custom fields from "demand" to project ?

ammar_k
Tera Contributor

Hello, 
we've added some custom fields to pm_prject, and added the same fields ( same names) to the demande table.
is it possible to copy those fields from demand to project while using the ui action "create project" ? 

thank you

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@ammar_k 

there is no property etc which controls this.

the fields to copied are hard-coded and not controller from system property

2 ways

1) update the OOTB script to add your custom fields

AnkurBawiskar_0-1758626570027.png

 

OR

2) use before insert BR on project table to set your custom fields from Demand (Recommended way)

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Anand2799
Giga Guru

Hi @ammar_k ,

 

OOB there is no property defined which you can use to copy additional values, however you can create a before BR on project table, glide record demand record and set the required fields.

 

Thanks

Anand

Brad Bowman
Kilo Patron
Kilo Patron

In the out of box UI Action you can do this within the if block that starts on line 21.  Just add a line for each field, followed by an update on the GlideRecord using 'current' to refer to the demand record from which the UI Action was executed, and 'project' to refer to the newly created project record such as:

project.u_field1 = current.u_field1;
...
project.update();

You can also / instead create a Business Rule on insert of the project table to do something similar.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@ammar_k 

there is no property etc which controls this.

the fields to copied are hard-coded and not controller from system property

2 ways

1) update the OOTB script to add your custom fields

AnkurBawiskar_0-1758626570027.png

 

OR

2) use before insert BR on project table to set your custom fields from Demand (Recommended way)

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

tejas1111
Tera Contributor

Yes, it’s possible. When you use Create Project UI action, it runs server-side logic (usually in a Script Include like DemandToProjectHelper). You can extend that script to map your custom fields.

Steps:

Go to the UI Action Create Project (on demand table).

Check what Script Include it calls (commonly DemandToProjectHelper.createProjectFromDemand).

Clone/extend that function and after project is created, copy values:

// inside your helper
project.your_custom_field = demand.your_custom_field;
project.u_another_field = demand.u_another_field;
project.update();


Test by creating a project from a demand and confirm values flow across.