How to create a copy case UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 12:00 AM
Hi,
We are currently trying to create a UI action to appear in CSM/FSM Workspace, that copies a case and creates a new case with the same information.
We have added the following script to the 'Workspace Client Script' field on the UI Action
var gr = current.sys_id.toString();
var newCase = new GlideRecord('sn_customerservice_case');
newCase.initialize();
newCase.from_email = current.from_email;
newCase.short_description = current.short_description;
newCase.company = current.company;
newCase.category = current.category;
newCase.subcategory = current.subcategory;
newCase.email_body = current.email_body;
newCase.work_notes = "Copied from Case " + current.number;
newCase.insert();
However, our cases are attached to a variety of tables extended from the 'sn_customerservice_cases' table. The new copied cases should be created on the exact same table as the original case. How can I ensure It is created on the same table, from one UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 12:52 AM
you cannot use current object in workspace client script.
why not use GlideAjax there and pass the current record sysId using g_form.getUniqueValue() and then in script include function have the logic define.
you can also pass the current table name to script include via GlideAjax using g_form.getTableName()
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 02:48 AM
Thank you for marking my response as helpful.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 04:55 AM - edited 03-09-2023 04:55 AM
@Ankur Bawiskar - thanks for the reply Ankur, we have now changed the way we have configured this so that a new case opens with all the copied information but it is not created so a user has the possibility to edit if necessary before submitted.
When selecting the copy case UI action, what script can we add to the UI action to ensure a comment is added to the work notes. We would like to add "Case copied from + the number of the original case"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 05:09 AM
@Ankur Bawiskar we are also struggling on copying attachments. This is because the case is not submitted yet so it can not get the sys id of the original case.