The CreatorCon Call for Content is officially open! Get started here.

Create a UI button on the form

siddharth26
Tera Guru

Hi All,

 

We need create a UI button named" create new" , if i click on that button i need a record to be created and saved in that table

 

for example :ABC is the table , in the form level i need button "create new" once i click that record should be created and saved in ABC table

thanks

sid

 

 

1 ACCEPTED SOLUTION

Maddysunil
Kilo Sage

@siddharth26 

You can create a UI action on that table, and you can set some fields data in newly created record if you want

 

var newRecord = new GlideRecord('your_table_name');
newRecord.initialize(); // Initialize a new record
newRecord.setValue('field_name', 'field_value'); // Set field values as needed
newRecord.insert(); // Insert the new record
action.setRedirectURL(current);

 

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

 

View solution in original post

4 REPLIES 4

BiancaK
Tera Expert

Hi @siddharth26 

 

Here is a link to the ServiceNow docs on how to create a New UI Action https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/list-adminis...

Maddysunil
Kilo Sage

@siddharth26 

You can create a UI action on that table, and you can set some fields data in newly created record if you want

 

var newRecord = new GlideRecord('your_table_name');
newRecord.initialize(); // Initialize a new record
newRecord.setValue('field_name', 'field_value'); // Set field values as needed
newRecord.insert(); // Insert the new record
action.setRedirectURL(current);

 

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

 

Hi Maddy,

 

thanks for the reply, could you please let me know what should write in condition in ui action and onclick in UI action

siddharth26_0-1710834119758.png

 

thanks

sid

 

@siddharth26 

Condition is used for button visibility.You can write your code in script part just below the condition.