- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 05:29 PM
Hii All,
Create below fields in Incident form –
1. ‘Critical Incident’ – Type True/False
2. ‘Marked as Critical by’ – Type String
3. ‘Marked Critical at’ – Type Date
Scenario :
1. When ‘Critical Incident’ is checked as TRUE, both fields 2 & 3 should be visible in form else they should be hidden. 2.‘Marked as Critical by’ should be auto – populated by the name of person who has marked ‘Critical Incident’ as TRUE and current date in ‘Marked Critical at’.
3. When ‘Critical Incident’ is checked as TRUE, the field should appear RED in colour.
-->i have created above 3 fields and i have done 1st point through ui policy for hidden and visible.
-->please help me on 2nd and 3rd point.
Regards,
Anjaneyulu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 07:44 PM
Hi,
you can refer this script to set color to field
use it as per your requirement
var control = g_form.getControl('u_marked_as_critical_by');
if(g_form.getValue('u_marked_as_critical_by').toString() == 'true'){
control.style.color = 'red'; // to set the color of field
}
else{
control.style.color = ''; // clear it
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 06:25 PM
Hi
although you did not specify in which experience (UI16, Service Portal, Workspace) you want to have that feature, it is not possible with OOTB means. The only alternative would be manipulating the DOM but this is not recommended.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 06:44 PM
Hii Maik,
it is on incident form all fields UI16
i have written onchange CS for 2nd point but date is not populating currently
var usr = g_user.getFullName();
var date = new Date();
if (newValue == 'true') {
g_form.setValue('u_marked_as_critical_by', usr);
g_form.setValue('u_marked_critical_at', date);
}
could you please help me on current date should be populated on 'u_marked_critical_at'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 06:51 PM
Hi
only providing a part of a Client Script is not helpful.
Please provide the complete Script as well as a screenshot from the configuration of the Client Script.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 07:44 PM
Hi,
you can refer this script to set color to field
use it as per your requirement
var control = g_form.getControl('u_marked_as_critical_by');
if(g_form.getValue('u_marked_as_critical_by').toString() == 'true'){
control.style.color = 'red'; // to set the color of field
}
else{
control.style.color = ''; // clear it
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader