
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello All,
How i can use IncidentState constants in Client scripts?
Is there a way we can use the constants in client scripts?
@Ankur Bawiskar any idea?
Regards,
Debasis
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
then something like this will help you
Note: This is just an example
var IncidentState = {
NEW: '1',
IN_PROGRESS: '2',
ON_HOLD: '3',
AWAITING_USER_INFO: '4',
AWAITING_EVIDENCE: '5',
RESOLVED: '6',
CLOSED: '7',
CANCELED: '8'
};
// Usage in client script
if (g_form.getValue('state') == IncidentState.NEW) {
alert('Incident is New');
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
no you cannot as those are defined in script include which is server side.
You can have your own constants in client script and then have logic.
what's your actual business requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
No There is no such requirement specific.
I want to use constants for example i want to set the value to New.
in order to do that in client script ideally we do like.
g_form.setValue('state', '1');
instead of direct backend values can i use some constants so that its readable and easy to understand.
giving direct backend values just to avoid this?
Regards,
Debasis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
then something like this will help you
Note: This is just an example
var IncidentState = {
NEW: '1',
IN_PROGRESS: '2',
ON_HOLD: '3',
AWAITING_USER_INFO: '4',
AWAITING_EVIDENCE: '5',
RESOLVED: '6',
CLOSED: '7',
CANCELED: '8'
};
// Usage in client script
if (g_form.getValue('state') == IncidentState.NEW) {
alert('Incident is New');
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader