Onload Client Script to make Variable mandatory is getting clear on load of form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 10:36 AM - edited 09-29-2024 10:39 AM
Hi All,
I have written Onload Client Script to make variable "is_this_it_sponsored" within the variable editor mandatory based on catalog task short description. When I enter the value and close the task. Then after the form reloads the value is getting clear and again showing mandatory .Can you all please help me with this.
function onLoad() {
if (g_form.getValue('short_description') == 'Review request details') {
g_form.setMandatory('variables.is_this_it_sponsored', true);
} else if (g_form.getValue('short_description') == 'Conduct Technical evaluation' ||
g_form.getValue('short_description') == 'Review integration request & schedule discovery meeting') {
g_form.setMandatory('variables.operational_impact', true);
g_form.setMandatory('variables.is_this_it_sponsored', false);
g_form.setDisplay('variables.is_this_it_sponsored', false);
} else if (g_form.getValue('short_description') == 'Conduct AI review' || g_form.getValue('short_description') == 'Conduct Cloud review' ||
g_form.getValue('short_description') == 'Conduct Infosec review') {
g_form.setDisplay('variables.operational_impact', true);
g_form.setReadOnly('variables.operational_impact', true);
} else {
g_form.setMandatory('variables.operational_impact', false);
g_form.setDisplay('variables.operational_impact', false);
g_form.setMandatory('variables.is_this_it_sponsored', false);
g_form.setDisplay('variables.is_this_it_sponsored', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:43 PM
Hi @Siddhesh Jadhav : How we can save the value using GlideRecord. Can you help me with some script example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:55 PM
@ukti
Here it is:
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'This is a test incident';
gr.category = 'network';
gr.priority = 2;
gr.assigned_to = 'YOUR_USER_ID';
var sys_id = gr.insert();
gs.info('New Incident Created with sys_id: ' + sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:30 AM
@ukti no! wrong!! abort!!! AI fail. You do not want or need a GlideRecord in your scenario, especially one like this.