Incident Fixed by change and incident caused by change on Change form

Gopi Kumar
Tera Contributor

Hi All,

we have an requirement, to restrict the incident that which already present in 'Incident Fix by change'  tab should not be able to select on the 'Incident caused by change tab' on change Module.

Incident Module

On the Incident form also, Change request which is selected on the 'change request' reference field. Should not be able to select on the caused by change

Pls suggest how we can achieve this requirement 

Thanks 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Gopi Kumar 

For incident form

For those 2 fields you will have to add reference qualifier for Caused by Change field

1) Go to configure dictionary of Caused by Change

2) In the advanced view select the reference qualifier as below in the advanced

javascript: 'sys_id!=' + current.rfc;

If you wish the same to happen for Change Request i.e CHG selected in Caused by Change should not be allowed in Change Request then do this

javascript: 'sys_id!=' + current.caused_by;

find_real_file.png

For Change Form: In order to restrict from adding same incident in "Incident Caused by change" do this

1) create before insert/update BR on incident table

Condition: current.caused_by != ''

2) Check if this CHG getting added in Incident's form "Caused by Change" field or not

Script:

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

    // Add your code here

var chg = current.caused_by;

if(current.rfc == chg){

gs.addErrorMessage('You are not allowed to same CHG in Caused by Change for this incident');

current.setAbortAction(true);

}

})(current, previous);

 

Regards
Ankur

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Gopi Kumar 

For incident form

For those 2 fields you will have to add reference qualifier for Caused by Change field

1) Go to configure dictionary of Caused by Change

2) In the advanced view select the reference qualifier as below in the advanced

javascript: 'sys_id!=' + current.rfc;

If you wish the same to happen for Change Request i.e CHG selected in Caused by Change should not be allowed in Change Request then do this

javascript: 'sys_id!=' + current.caused_by;

find_real_file.png

For Change Form: In order to restrict from adding same incident in "Incident Caused by change" do this

1) create before insert/update BR on incident table

Condition: current.caused_by != ''

2) Check if this CHG getting added in Incident's form "Caused by Change" field or not

Script:

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

    // Add your code here

var chg = current.caused_by;

if(current.rfc == chg){

gs.addErrorMessage('You are not allowed to same CHG in Caused by Change for this incident');

current.setAbortAction(true);

}

})(current, previous);

 

Regards
Ankur

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

Hi Ankur,

The Br is working as expected, even though we don't give the reference qualifiers on 'Caused by Change' & "Change Request' Dictionary

 

Thanks

Glad to hear

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