Form being submitted without mandatory fields filled in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 01:07 AM
On the new_call table users are able to save the form without the mandatory fields being completed. i.e. when clicking on new call and clicking on create task it re-directs to the call type tale e.g. incident, service request. However, this can be done without the mandatory fields being filled out on the form. I have checked any UI actions and policies but can't see anything that will be causing this. Any ideas on how to fix this issue?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2019 03:34 AM
Hi,
Can you share your current code which redirects to the new page?
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
‎08-16-2019 04:02 AM
onlick: redirectToTask();
function redirectToTask() {
var callType = g_form.getValue('call_type');
var caller = g_form.getValue('caller');
var onBehalf = g_form.getValue('u_on_behalf_of');
var contactType = g_form.getValue('contact_type');
if (contactType == ''){
contactType = 'Phone';
}
var shortDescription = g_form.getValue('short_description');
var description = g_form.getValue('description');
var company = g_form.getValue('company');
var sys_id = '';
if(callType == 'incident'){
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = caller;
gr.state = 2;
gr.u_on_behalf_of = onBehalf;
gr.contact_type = contactType;
gr.short_description = shortDescription;
gr.u_unknown_caller = g_form.getValue('u_unknown_caller_name');
gr.u_unknown_user_business_phone = g_form.getValue('u_unknown_user_business_phone');
gr.u_not_found_details = g_form.getValue('u_not_present_details');
gr.company = company;
gr.assignment_group = 'd625dccec0a8016700a222a0f7900d06';
var sys_id = gr.insert();
var url = g_form.getValue('call_type') + '.do?sys_id=' + sys_id;
window.open(url, target="_blank");
} else if(callType == 'password_reset'){
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = caller;
gr.u_on_behalf_of = onBehalf;
gr.contact_type = contactType;
gr.short_description = 'Password Reset Request';
gr.description = 'Request to Reset Password for ' + g_form.getDisplayValue('u_business_service') + "\n\nNotes:\n\n" + description;
gr.u_unknown_caller = g_form.getValue('u_unknown_caller_name');
gr.u_unknown_user_business_phone = g_form.getValue('u_unknown_user_business_phone');
gr.company = company;
gr.assignment_group = 'd625dccec0a8016700a222a0f7900d06';
gr.priority = 3;
gr.state = 6;
gr.service_offering = g_form.getValue('u_business_service');
gr.u_cause_code = 'User Input';
gr.close_code = 'Solved Remotely (Permanently)';
gr.u_first_time_fixed = true;
gr.close_notes = 'Password Reset at Request of Caller';
var sys_id = gr.insert();
} else if(callType == '3rd_party_access_request'){
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = caller;
gr.u_on_behalf_of = onBehalf;
gr.contact_type = contactType;
gr.short_description = '3rd Party Supplier Remote Access Request';
gr.description = 'Request from 3rd Party Supplier to access IT Environment.\n\n3rd Party Reference is: ' + g_form.getValue('u_rd_party_reference');
gr.u_unknown_caller = g_form.getValue('u_unknown_caller_name');
gr.u_unknown_user_business_phone = g_form.getValue('u_unknown_user_business_phone');
gr.company = company;
gr.assignment_group = 'd625dccec0a8016700a222a0f7900d06';
gr.priority = 3;
gr.state = 6;
gr.u_cause_code = '3rd Party Issue';
gr.close_code = 'Solved Remotely (Permanently)';
gr.u_first_time_fixed = true;
gr.close_notes = 'Request from 3rd Party Supplier to access IT Environment.\n\n3rd Party Reference is: ' + g_form.getValue('u_rd_party_reference');
var sys_id = gr.insert();
} else if(callType == 'status_call'){
var sys_id = g_form.getValue('transferred_to');
var url = 'task.do?sys_id=' + sys_id;
window.open(url, target="_blank");
} else if(callType == 'general_inquiry'){
var gr = new GlideRecord('u_information_request');
gr.initialize();
gr.u_caller = caller;
gr.u_unknown_caller = g_form.getValue('u_unknown_caller_name');
gr.u_unknown_user_business_phone = g_form.getValue('u_unknown_user_business_phone');
gr.u_not_found_details = g_form.getValue('u_not_present_details');
gr.contact_type = contactType;
gr.company = company;
gr.description = description;
gr.assignment_group = 'd625dccec0a8016700a222a0f7900d06';
gr.state = 2;
var sys_id = gr.insert();
var url = 'u_information_request.do?sys_id=' + sys_id;
window.open(url, target="_blank");
} else if(callType == 'complaint' || callType == 'compliment' || callType == 'suggestion'){
var gr = new GlideRecord('u_account_delivery_management');
gr.initialize();
gr.u_unknown_caller = g_form.getValue('u_unknown_caller_name');
gr.u_unknown_user_business_phone = g_form.getValue('u_unknown_user_business_phone');
gr.u_not_found_details = g_form.getValue('u_not_present_details');
gr.contact_type = contactType;
gr.u_caller = caller;
gr.u_on_behalf_of = onBehalf;
gr.company = company;
if (callType == 'complaint'){
gr.u_adm_choice_type = 'Complaint';
gr.priority = 4;
}
if (callType == 'compliment'){
gr.u_adm_choice_type = 'Compliment';
gr.priority = 5;
}
if (callType == 'suggestion'){
gr.u_adm_choice_type = 'Suggestion';
gr.priority = 5;
}
gr.description = description;
gr.assignment_group = '7e7678e9379cbe00909584f643990e83';
gr.state = 2;
var sys_id = gr.insert();
var url = 'u_information_request.do?sys_id=' + sys_id;
// window.open(url, target="_blank");
}
var gr2 = new GlideRecord('new_call');
gr2.caller = caller;
gr2.u_on_behalf_of = onBehalf;
gr2.u_unknown_caller_name = g_form.getValue('u_unknown_caller_name');
gr2.u_unknown_user_business_phone = g_form.getValue('u_unknown_user_business_phone');
gr2.u_not_present_details = g_form.getValue('u_not_present_details');
gr2.call_type = callType;
gr2.company = company;
gr2.contact_type = contactType;
gr2.short_description = shortDescription;
if(callType != 'status_call'){
gr2.transferred_to = sys_id;
}
if (callType == 'password_reset' || callType == 'suggestion' || callType == 'compliment' || callType == '3rd_party_access_request'){
var gr = new GlideRecord('task');
gr.addQuery('sys_id', sys_id);
gr.query();
gr.next();
alert (gr.number + ' Created');
} else if (callType == 'complaint'){
alert ('Complaint Created');
} else {
gr2.transferred_to = g_form.setValue('transferred_to');
}
gr2.u_business_service = g_form.getValue('u_business_service');
gr2.request_item = g_form.getValue('request_item');
gr2.insert();
g_form.clearValue('caller');
g_form.clearValue('u_on_behalf_of');
g_form.clearValue('call_type');
g_form.clearValue('company');
g_form.setValue('contact_type', 'phone');
g_form.clearValue('short_description');
g_form.clearValue('transferred_to');
g_form.clearValue('u_business_service');
g_form.clearValue('request_item');
g_form.clearValue('description');
g_form.clearValue('u_unknown_caller_name');
g_form.clearValue('u_unknown_user_business_phone');
g_form.clearValue('u_not_present_details');
g_form.clearValue('u_rd_party_reference');
if (callType == 'sc_request'){
window.open('/itsp?id=sc_category', 'https://nwcsu.service-now.com/itsp?id=sc_category');
}
// window.location.assign('/new_call.do?sys_id=-1&sysparm_stack=new_call_list.do');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2019 05:04 AM
Did you manage to have a look at the code?