Create new table records on clicking ui action button from another table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-13-2024 11:57 PM
So I have a requirement ,when I select list of records in list view in table A and click ui action button (Approve) those records should be transferred and create new record in Table B, Also those records in table A should updated status as approved. How to achieve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2024 03:35 AM
Hi @Sharath807,
I tried on list view now please use below script it is working fine for me
function funcList() {
var selectedIds = g_list.getChecked();
var ids = selectedIds.split(',');
alert('status - ' + ids.length);
for (var i = 0; i < ids.length; i++) {
alert("Inside for loop = " + i);
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = "Test 12345";
gr.insert();
}
}
Result
There are two button on my Case table when I selected both the record and click on UI Action it creates two record in Incident table
Before 475 Records
After 477 Records
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2024 05:23 AM
@Community Alums Hi when i click approve button its showing popup as.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2024 05:47 AM
Hi @Sharath807 ,
That was an alert, you can remove that. Script will work in that case also.
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2024 01:20 AM - edited ā06-14-2024 01:27 AM
hello @Sharath807,
You can use :
var selSysIds = g_list.getChecked();
variable selSysIds will have comm separated list of sysIds of selected records and then you can use those sysId while creating records in another table using below code
var sysIdList = selSysIds.split(',');
alert('status - '+selSysIds);
for (var i=0;i<=sysIdList.length;i++)
{
var gr = new GlideRecord('sys_approver');
gr.initialize();
gr.sys_id = -1;
gr.doucment_id = sysIdList[i];
//other mandatory fileds
gr.insert();
}
Use loop for creation of record.
Please mark helpful/correct if this helped.
Regards,
Sanket Landge
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-14-2024 02:47 AM