Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Create new table records on clicking ui action button from another table

Sharath807
Tera Contributor

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.

10 REPLIES 10

Community Alums
Not applicable

Hi @Sharath807 ,

I tried your problem in my PDI and it works for me

For example your Table A = Case Table (sn_customerservice_case) and Table B - Incident table(incident)

Create UI Action on Case table i.e, Table A and add below code 

var gr = new GlideRecord('incident');
gr.initialize();
gr.sys_id = -1;
gr.u_case = current.sys_id;
gr.insert();
action.setRedirectURL('incident.do?sys_id='+gr.sys_id)

SarthakKashyap_0-1718351029886.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

Why do you set the sys_id = -1?

Community Alums
Not applicable

I thought before like @Sharath807  want to navigate to new record i.e., I gave sys_id as -1 there

 

@Community Alums Hi , actually i need the Ui action button list banner, and when i select list of records from the list,and click button that selected list should create record in other table.( eg. 5 records selected, 5 record should create in other table)