How to set field value same as another field

raj149
Giga Guru

Hello Experts,

 

In incident form there is 2 fields called status(state) and Incident state(incident_state).

My requirement is 

If state is selected with example work in progress how to set same value in incident state field.

Tested with business rule (before insert and update)

Filter condition is status changes 

Set field values is Incident state same as state.

But it is not working because choices backend values is different in Incident state field.

Status :

New (1)

Assigned(8)

Work in progress (6)

Pending(-5)

Resolved(7)

Cancelled(10)

Incident state:

New (1)

Assigned(4)

Work in progress (7)

Pending(-2)

Resolved(5)

Cancelled(-6)

 

How to achieve this by using business rule script.

 

 

Thanks in advance.

 

Best regards,

Raj.

 

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Out-of-the-box, there is already a business rule which covers this. Why are you deviating from this?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hello @Mark Roethof 

 

Thanks for your response.

1 year ago as per requirement they have changed the choices. (Choices mentioned above).Out of the box business rule is not working because  incident state is having different choice backend values.

 

Best regards,

Raj

Oke, then update the out-of-the-box business rule, or deactivate it and create a new one with same order.

 

Script could be something like below. Just really quickly drafted this in 30 seconds, so untested, etc..

 

 

	var incident_state = '1'; // New

	switch(current.getValue('state')) {
		case '8': // Assigned
			incident_state = '4';
			break;
		case '6': // Work in progress
			incident_state = '7';
			break;
		case '...': // Etc
			incident_state = '...';
			break;
	}

	current.incident_state = incident_state;

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Mark Roethof
Tera Patron
Tera Patron