Perform server-side UI actions ignoring required fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 05:50 PM
I would like to execute the UI action "Copy Record" with the required fields left blank.
It has the same specifications as copying incident management records.
Currently, if a required field is left blank, a message prompting for input will be displayed.
I want to perform a record copy ignoring required fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 06:28 PM
Hey @bonsai,
You can try this process.
Create a Client UI Action.
function copyIncident() {
// make fields un-mandatory on the form
g_form.setMandatory("caller_id", false);
g_form.setMandatory("short_description", false);
var gax = new GlideAjax("CopyIncident");
gax.addParam("sysparm_name", "copyIncidentFunc");
gax.getXML(callbackFunction);
function callbackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage("Incident Created: "+answer);
}
}
Make all of your fields un-mandatory and then call a Client Callable Script Include.
var CopyIncident = Class.create();
CopyIncident.prototype = Object.extendsObject(AbstractAjaxProcessor, {
copyIncidentFunc: function() {
var gr = new GlideRecord("incident");
gr.setWorkflow(false);
gr.initialize();
gr.insert();
return ""+gr.number;
},
type: 'CopyIncident'
});
In this way, you can create incidents without filling the Required/Mandatory Fields.
Incident used to create a new one:
New Incident Created:
Kindly appreciate the efforts of community contributors by marking appropriate response as the correct solution and helpful, this may help other community users to follow the right solution in the future.
Thanks,
Hamza
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 08:32 PM
Is it possible to copy fields?
Also, when copying, is there an efficient way to copy all fields of a record?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 08:53 PM
this is for a custom table and your UI action is a custom one?
If this is for your custom table and custom UI action is created then you can add that logic as per your requirement
Please share your UI action script and what changes you have done so far
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 07:22 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader