gpt-4-0314· OpenAI
Arena Human Preference 55K
write a servicenow business rule in javascript that aborts an update to the sys_user…
- User
write a servicenow business rule in javascript that aborts an update to the sys_user table if the email field is changed and is a duplicate of another record
- Assistant
Here is a ServiceNow business rule in JavaScript that aborts an update to the sys_user table if the email field is changed and is a duplicate of another record:
(function executeRule(current, previous /*null when async*/) { // Check if the email field has changed if (current.email != previous.email) { // Create a new GlideRecord to search for duplicate email addresses var duplicateUser = new GlideRecord('sys_user'); // Set the query parameters to search for records with the same email duplicateUser.addQuery('email', current.email); duplicateUser.addQuery('sys_id', '!=', current.sys_id); // Execute the query duplicateUser.query(); // Check if a duplicate record exists if (duplicateUser.next()) { // Abort the update and display an error message current.setAbortAction(true); gs.addErrorMessage('The email address is already in use. Please enter a unique email address.'); } } })(current, previous);
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.