- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 09:59 PM
PLease how do I achieve this?
Solved! Go to Solution.
 
					
				
		
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2024 06:34 AM - edited 10-06-2024 06:48 AM
@Mimi Edet , you can achieve this without doing any scripting, and in a ServiceNow-recommended way using a state model flow. it is very easy to configure, here is a document around it that may be of some help, but let me know if you get stuck in configuring this I can guide you.
All > State Management > State Models (this is the starting point for the configuration)
 
					
				
		
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2024 08:16 AM
Yes, indeed, I just tried it in my instance, you would need four state models for it, I'm attaching the screenshots of same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 10:14 PM
Hi @Mimi Edet ,
If you want to show state dropdowns you can achieve this by writing a onLoad Client script. Give the conditions on the respective button to be visible on the form.
example for client script, you can modify based on your need:
function onLoad() {
	var incState = g_form.getValue('state');					//getting state value of current from
    if (g_form.isNewRecord() && incState == '1') {				//checking the record is new or not
		g_form.setReadOnly('state', true);						//making state field readonly
    }
	
	else if(incState == '5'){									//checking the state value is assigned or not
		g_form.removeOption('state','1');						//removing "New" option from state
		g_form.removeOption('state','3');						//removed "On Hold" option from state
		g_form.removeOption('state','6');						//removed "Resolved" option from state
		g_form.removeOption('state','7');						//removed "Closed" option from state
		g_form.removeOption('state','8');						//removed "Canceled" option from state
	}
	else if(incState == '2'){									//checking the state value is "In progress" or not
		g_form.removeOption('state','1');						//removed "New" option from state
		//g_form.removeOption('state','5');						//removed "Assigned" option from state
		g_form.removeOption('state','7');						//removed "Closed" option from state
		g_form.removeOption('state','8'); 						//removed "Canceled" option from state
	}
	else if(incState == '3'){									//checking the state value is "On Hold' or not
		g_form.removeOption('state','1');						//removing "New" option from state
		g_form.removeOption('state','5');						//removed "Assigned" option from state
		g_form.removeOption('state','6');						//removed "Resolved" option from state
		g_form.removeOption('state','7');						//removed "Closed" option from state
		g_form.removeOption('state','8'); 						//removed "Canceled" option from state
	}
}
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2024 07:05 AM
Can I use this script in Business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2024 07:22 AM
Hi @Mimi Edet
You have to write client script, the below example is for onload catalog client script.
Thanks,
Pradeep
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2024 03:20 AM
Hi @Mimi Edet ,
If my solution helps you please accept the solution and close the thread.
Thanks,
Pradeep
Regards,
Pradeep
