- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 04:32 AM
Hi Developers,
I want to make visible and mandatory ,explanation field once clicked on Reject button when we fill the details state changes to complete and record should be save.
Below is the UI Action &client script
client sacript:Onload()
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.setVisible('u_explanation',false);
}
Ui Action :
when i clicked on button field is visible and throwing error message but not changing state as nothing is happened ..
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 09:47 AM
Great! It looks like you marked your own response as the correct answer, which may be confusing to others that read this later.
I felt I covered that above pretty well (first) and included the script which pointed you in right direction on combination of client+server side code
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
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
06-29-2020 07:55 AM
Hi,
please share updated code
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
06-29-2020 07:56 AM
Hi,
please share updated script
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
06-29-2020 08:45 AM
I tried different script its working now, hope this will help to others,
Ui Action script _
function rejectAnalysis(){
if (g_form.getValue('u_explanation') == '') {
// Remove any existing field message, set comments mandatory, and show a new field message
try {
g_form.hideFieldMsg('u_explanation');
} catch(e) {}
g_form.setMandatory('u_explanation', true);
g_form.showFieldMsg('u_explanation', getMessage('Please provide the explanation '), 'error');
g_form.addErrorMessage('Please enter comments in the Explnanation ');
return false; // Abort submission
}
// Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'reject_quality'); // MUST call the 'Action name' set in this UI Action
}
// Ensure call to server side function with no browser errors
if (typeof window == 'undefined')
serverReopen();
function serverReopen() {
// Set Incident state to active, update and reload the record
current.u_quality_state = 4;
current.update();
gs.addInfoMessage(gs.getMessage("Quality Analysis Submitted."));
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 09:47 AM
Great! It looks like you marked your own response as the correct answer, which may be confusing to others that read this later.
I felt I covered that above pretty well (first) and included the script which pointed you in right direction on combination of client+server side code
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader