Auto Populate CI value from Incident's CI in Incident Task at time of creation from Incident

v-jai
Kilo Expert

Please help to achieve below scenario:

Incident task to have Configuration item field on the form which will auto-populate with Incident CI at the time of creation from an Incident.

1 ACCEPTED SOLUTION

Suseela Peddise
Kilo Sage

Hi,

1. Create a onBefore business rule on incident_task table.

find_real_file.png

 

And add below line of script in Advanced tab

current.cmdb_ci=current.incident.cmdb_ci;

This method shows the field value on form once you save the record.

2. If you want to auto populate the CI value as soon as form load , then use 'display' business and write onLoad client script to populate

find_real_file.png

And add below line of script 

g_scratchpad.CIpopup=current.incident.cmdb_ci;

And then onLoad client script:

 g_form.setValue('cmdb_ci',g_scratchpad.CIpopup);

 

You can also use GlideAjax or getReference methods

If I have answered your question, please mark my response as correct and/or helpful.

 Thanks,

Suseela P.

View solution in original post

5 REPLIES 5

Daniel O_Connor
Kilo Guru

Hey,

 

You can do this a few ways, but it somewhat depends on how you are creating the Task child record in the first place.

If you have this via a workflow, with say flow designer, you can just have the TASK field copy from the inherited parent. 

You could use a Before Update Business Rule on the incident table like below 

var gr=new GlideRecord('u_incident_task');

gr.initialize();

gr.short_description=current.short_description;
gr.cmdb_ci=current.cmdb_ci

gr.insert();

If it returns the sys.id might need to change around to be a getvalue type of syntax.

 

How are you creating the Task? 

Hi Daniel , 

 

Task creation is by Clicking on New button at Related List of Incident form.

find_real_file.png

Cool so you will need to create a Business Rule, which will see the linked Task and then auto populate the CI

 

@Suseela has replied there with steps on how to do

Suseela Peddise
Kilo Sage

Hi,

1. Create a onBefore business rule on incident_task table.

find_real_file.png

 

And add below line of script in Advanced tab

current.cmdb_ci=current.incident.cmdb_ci;

This method shows the field value on form once you save the record.

2. If you want to auto populate the CI value as soon as form load , then use 'display' business and write onLoad client script to populate

find_real_file.png

And add below line of script 

g_scratchpad.CIpopup=current.incident.cmdb_ci;

And then onLoad client script:

 g_form.setValue('cmdb_ci',g_scratchpad.CIpopup);

 

You can also use GlideAjax or getReference methods

If I have answered your question, please mark my response as correct and/or helpful.

 Thanks,

Suseela P.