how to auto populate reference field values to incident form using the before business rule

t venkatesh1
Tera Contributor

Hi,

I want to get the configuration item and assignment group auto populate when the incident created using before BR.

please suggest the script how get the above values.

examples: Configuration item = server,

                  assignment group= test group.

 

regards,

venkatesh t

2 ACCEPTED SOLUTIONS

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @t venkatesh1 ,

 

Whats your condition here ?

 

You can add the below code :

 

current.assignment_group = ''pass the sys_id of the group"

current.configuration_item="sys_id of the CI"

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

Jitendra Diwak1
Kilo Sage

Hi @t venkatesh1,

 

By using before Business rule it can be achieved by below code:

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.assignment_group= '019ad92ec7230010393d265c95c260dd';
	current.cmdb_ci = 'b4fd7c8437201000deeabfc8bcbe5dc1';

})(current, previous);

 

But thing is when you load the form then that time field will be empty and when you save the record then it will be auto populate.

But if you want to auto populate when the form is loaded then you need to create the onLoad client script to get this and code is shared below:

 

Please mark my answer as accept if resolves your query.

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

View solution in original post

4 REPLIES 4

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @t venkatesh1 ,

 

Whats your condition here ?

 

You can add the below code :

 

current.assignment_group = ''pass the sys_id of the group"

current.configuration_item="sys_id of the CI"

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Jitendra Diwak1
Kilo Sage

Hi @t venkatesh1,

 

By using before Business rule it can be achieved by below code:

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.assignment_group= '019ad92ec7230010393d265c95c260dd';
	current.cmdb_ci = 'b4fd7c8437201000deeabfc8bcbe5dc1';

})(current, previous);

 

But thing is when you load the form then that time field will be empty and when you save the record then it will be auto populate.

But if you want to auto populate when the form is loaded then you need to create the onLoad client script to get this and code is shared below:

 

Please mark my answer as accept if resolves your query.

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

Hi @t venkatesh1,

 

By using before Business rule it can be achieved by below code:

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.assignment_group= '019ad92ec7230010393d265c95c260dd';//replace with your group sys id
	current.cmdb_ci = 'b4fd7c8437201000deeabfc8bcbe5dc1';// replace with your config item

})(current, previous);

 

But thing is when you load the form then that time field will be empty and when you save the record then it will be auto populate.

But if you want to auto populate when the form is loaded then you need to create the onLoad client script to get this and code is shared below:

function onLoad() {
   //Type appropriate comment here, and begin script below
   g_form.setValue('assignment_group','019ad92ec7230010393d265c95c260dd');// 2nd para will take sys id as it is refrence field 
   g_form.setValue('cmdb_ci', 'b4fd7c8437201000deeabfc8bcbe5dc1');// 2nd para will take sys id as it is refrence field 
   
}

 

Please mark my answer as accept if resolves your query.

 

Thanks

Jitendra

Please accept my solution if it works for and thumps up.

Community Alums
Not applicable

Hi @t venkatesh1 ,

Please create Before Business Rule, add appropriate condition and add below script

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.assignment_group= '<sys_id of assignment Group>';
	current.cmdb_ci = 'sys_id of  of cmdb_ci';

})(current, previous);

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak