Copy button on a table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2017 08:47 AM
I'm trying to create a copy button on a u_epic_change_request table. I would like all fields to be copied from the original table to the new table except for what is the 'ABC' tab:
How would I go about doing that? I know I have to create a UI Action, but I'm not sure about the script and condition.
Thank you,
Sarah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2017 09:24 AM
Hello
To copy a record with a UI Action you can simply add
current.insert();
in your UI Action script field.
Now if you want to NOT copy some fields you can clear them, since you will do a "current.insert()" and not a "current.update()", it will not impact your original record
so you will have to write, and repeat for each field of your tab "ABC" the following line:
current.field_name.setValue('');
You should also do it for your "number" field or it will duplicate the number as well.
The script of your UI Action should look like this:
Hope it helps you! If it is the case do not hesitate to hit the button helpful on this post and mark your question answered!
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2017 09:24 AM
Hi Sarah
Since you're not looking at creating an exact replica (or clone if you like) of the record, you can look at the "Create Problem", "Create Requests" and other similar UI Actions on the Incident table for an idea of what scripting to do.
The "Create Problem" UI Action can be seen here: /sys_ui_action.do?sys_id=2f43c471c0a8006400a07440e49924c2
Hope this helps
Shahid

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2017 10:08 AM
Hi Sarah,
You can use below script
createabc();
function createabc() {
// (1) Copy fields into a new table
var abc1 = new GlideRecord("Table_name");
abc1.initialize();
abc1.short_description = current.short_description;
abc1.state = current.state;
abc1.description = current.description;
//abc1.fieldname=current.fieldname; & so on.
abc1.work_notes = "Generated from Epic Change Request " + current.number;
abc1.insert();
// (2) Redirect webpage
gs.addInfoMessage(gs.getMessage("ABC{0} converted from Epic Change Request {1}", [abc1.number, current.number]));
action.setRedirectURL(abc1);
var redirectURL = action.getRedirectURL();
action.setRedirectURL(redirectURL);
action.setReturnURL(current);
}