
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 09-13-2021 02:44 PM
Situation
When opening a Now Experience page with a List component and click on the'New' button, nothing happens.
You would expect that clicking on the New button would open a new page to allow you to create a new record. For some unexplainable phenomenon it's not the case, but don't worry there is a ...
Solution
to make the 'New' button in the List component work.
The list component has been updated in Quebec Patch 8 and Rome Patch 1 (*) and now exposes an event "New Button Clicked" that we can use to bridge this gap.
(*) to be released on September 16, 2021,
Steps
In your Now Experience page containing the List component follow these steps:
1. Open the Page scripts section (</> symbol in left menu bar)
2.click "Add"
a) name the script "Open Record from List",
b) add "recordRoutesMapping" as a script include
c) add the following code body:
function handler({api, helpers, event, imports}) {
const { buildDefaultRoutePayload
} = imports["global.recordRoutesMapping"]();
var route = 'record';
var targetRoute = '';
const defaultRoutePayload = buildDefaultRoutePayload(route, targetRoute, event);
api.emit('NAV_ITEM_SELECTED', defaultRoutePayload);
}
3. Close the Page scripts section to return to the "Pages" section.
4. Click the list component and switch to the "Events" tab.
5. Connect the New button to the Script
a. Under the "New Button Clicked" dropdown, click "Add a new event handler"
b. Select the "Open Record from List" script, then click "Add".
6. Save the page
7. Launch your experience, click on the New button and Voila! it now opens a new page to allow you to create a new record.
- 4,814 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Marc,
I am new to the UI builder. I wanted to understand how do you know if you have to use api.emit instead of helpers.navigate.to in this scenario? Also, why should i use "NAV_ITEM_SELECTED" event only? How do i know what what all other events i have that i can use in api.emit? can you please help?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
The helpers.navigate.to function is one among many shortcuts that the helpers API provides. If one helpers function performs what you need you're all set.
You can find more information on the Developer API reference page: https://developer.servicenow.com/dev.do#!/reference/api/sandiego/client/helpersAPI
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Marc Mouries I am trying to use this script to create a new record in Tokyo Patch 1a in a related list. Would this work there? I just get redirected to a page that says "The page you are looking for could not be found."
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have the same @Tim_Urben problem

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Same issue @Mahmoud Hassan @Tim_Urben did you solve this issue?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Attention: @Marc Mouries @Mahmoud Hassan @Tim_Urben @Kopresh
🌟 Great news! I've come up with an effective solution to tackle this issue. It appears to be closely linked with the name of the record page that was generated within your workspace. While the default page name is 'record,' I've customized mine to 'main-record.' To address this, all you need to do is adjust the page name to match your specific {{record page name}}.
This adjustment should seamlessly resolve the issue at hand
A) Go to this table: sys_declarative_action_payload_definition
B) Search for the record with key "CREATE_NEW_RECORD"
C) in the payload section, change route to {{your page name}} for example main-record or basic-record.
NOTE: this will resolve the related list new button, you can apply the same thing on sys_ux_form_action
Good luck