Clone case along with variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I have a requirement to duplicate a customer service case along with all its variables in variable editor.
Suppose a case is created and when analyst make field Private(custom field) as true, then a duplicate case should get created and assigned to SC-HR team with all values same as current record along with all it's variable. How to achieve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello,
Create a Ui action on the same table and write a server script to copy fields from existing record to new record.
>>>In your case write a before business rule with condition custom field marked to true and use the below script..<<<
var newRecord = new GlideRecord(current.getTableName()); // Create a new GlideRecord for the current table
newRecord.initialize(); // Initialize the new record
// Loop through all fields of the current record and copy their values
var fields = current.getFields();
for (var i = 0; i < fields.size(); i++) {
var field = fields.get(i);
var descriptor = field.getED();
var fieldName = descriptor.getName();
// Exclude system fields (e.g., sys_id, sys_created_on, sys_updated_on) and empty fields if desired
if (!fieldName.startsWith('sys_') && current[fieldName] != null) {
newRecord[fieldName] = current[fieldName];
}
}
newRecord.insert(); // Insert the new record
Please Mark my answer helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
you can use OOTB Cart API OR CatItem API and set all the variables again on fresh HR case
see these links
How to Submit record producer using script ServiceNow
Submit the record producer from script
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hope you are doing good.
Did my reply answer your question?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
