Create a new record with a UI action

__17
Tera Expert

I would like to create a UI action like the one below and implement a spec that sets the value by default when creating a new record.

However, when I execute a UI action on the record list screen, a "No records selected" popup is output.

Can you tell me the UI action to create a new record?

var new_rec = new GlideRecord("table_name");

new_rec.initialize();

new_rec.setValue("field_name1","value1");
new_rec.setValue("field_name2","value2");
new_rec.setValue("field_name3","value3");

action.setRedirectURL(new_rec);
1 ACCEPTED SOLUTION

var new_rec = new GlideRecord("table_name");

new_rec.initialize();

new_rec.setValue("field_name1","value1");
new_rec.setValue("field_name2","value2");
new_rec.setValue("field_name3","value3");

action.openGlideRecord(new_rec);

 

The above code solved it!

I didn't use it because I thought that ".insert ()" would save the record.
I was also considering closing the record without saving it.

Thank you.

View solution in original post

5 REPLIES 5

__17
Tera Expert

Thank you for both of you.
I couldn't explain my requirements.

Immediately after clicking the "New" button, I wanted to display the new record screen on the screen without saving the record.
I also wanted to set the field value of the new record displayed on the screen to the same value as the default value.

I created a new UI action to avoid the specification that the value is forcibly set even if it is left blank when the default value is set.