- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 04:02 AM
Hello,
We have customized the UI page 'HR Suspend Dialog' which is being called from the 'Suspend' and 'Suspend case' UI action. As per the customization, Work notes field is NOT displayed always. It is displayed only when certain suspension reason is selected. We want the same functionality in HR Agent workspace as well.
If we look into the OOTB code for workspace , Work notes field has been defaulted and displayed always with below code:
https://devxxxx.service-now.com/sys_ui_action.do?sys_id=b65370019f22120047a2d126c42e701d&sysparm_view=&sysparm_record_target=sys_ui_action&sysparm_record_row=1&sysparm_record_list=sys_id%3Db65370019f22120047a2d126c42e701d%5EORDERBYorder&sysparm_record_rows=1
I want to display work notes field only when certain reason is selected. Please advice.
Solved! Go to Solution.
- Labels:
-
Agent Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:05 AM
Hi Pooja,
Consider it as a workaround to fulfill your requirement. You can try to show two modals
- Take Reason
- Take Work Notes
When user has provided the reason for which you want to show the work notes field, show another modal to take work notes from user. See the below script for reference.
function onClick(g_form) {
var type = [{
type: 'choice',
name: 'u_type',
label: 'New Type',
mandatory: true,
value: getMessage(' -- Select -- '),
choices: [{
displayValue: 'Best',
value: 'Best'
},
{
displayValue: 'Bad',
value: 'Bad'
}
]
}];
var workNote = [{
type: 'textarea',
name: 'work_notes',
label: 'New Type',
mandatory: true,
value: getMessage('Work notes')
}];
g_modal.showFields({
title: 'Enter New Values',
fields: type,
size: 'lg',
height: 'md'
}).then(function(selectedType) {
if (selectedType.updatedFields[0].value == 'Best') {
g_modal.showFields({
title: 'Enter New Values',
fields: workNote,
size: 'lg',
height: 'md'
}).then(function(newWorkNote) {
g_form.setValue('u_type', selectedType.updatedFields[0].value);
g_form.setValue('work_notes', newWorkNote.updatedFields[0].value);
g_form.save();
});
} else {
g_form.setValue('u_type', selectedType.updatedFields[0].value);
g_form.save();
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 06:05 AM
Hi Pooja,
Consider it as a workaround to fulfill your requirement. You can try to show two modals
- Take Reason
- Take Work Notes
When user has provided the reason for which you want to show the work notes field, show another modal to take work notes from user. See the below script for reference.
function onClick(g_form) {
var type = [{
type: 'choice',
name: 'u_type',
label: 'New Type',
mandatory: true,
value: getMessage(' -- Select -- '),
choices: [{
displayValue: 'Best',
value: 'Best'
},
{
displayValue: 'Bad',
value: 'Bad'
}
]
}];
var workNote = [{
type: 'textarea',
name: 'work_notes',
label: 'New Type',
mandatory: true,
value: getMessage('Work notes')
}];
g_modal.showFields({
title: 'Enter New Values',
fields: type,
size: 'lg',
height: 'md'
}).then(function(selectedType) {
if (selectedType.updatedFields[0].value == 'Best') {
g_modal.showFields({
title: 'Enter New Values',
fields: workNote,
size: 'lg',
height: 'md'
}).then(function(newWorkNote) {
g_form.setValue('u_type', selectedType.updatedFields[0].value);
g_form.setValue('work_notes', newWorkNote.updatedFields[0].value);
g_form.save();
});
} else {
g_form.setValue('u_type', selectedType.updatedFields[0].value);
g_form.save();
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 01:49 AM
Hi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 02:03 AM
Hi, you can update the input element type to date(type="date") in the UI Page HTML code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2022 02:46 AM
Hi Vamis,
We are trying to implement this in workspace client script of the UI Action using g_modal method, not in the UI Page