- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 10:18 PM
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);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 11:07 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 10:19 PM
Hi there,
Where is the .insert()?
Or do you want a new record to open on your screen, which is not saved yet, though with some fields populated already?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 11:07 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 11:10 PM
Don't see any changes to the original code? So what the solution now? Or was my answer sufficient and correct?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 11:22 PM
Hi,
without having insert() the record won't be inserted
Don't you wish to insert the record and then open the record?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader