UIB how to create new record from Landing page

Nikolaj2
Tera Guru

Hi, 

Have anyone tried creating a button from a landing page with the purpose of creating a new record?

Basically what i want to achieve is close to the "New" button on lists, but it needs to be a more simpe version with no steps as the default version has. I need a button on one of my HR landing pages which, once clicked does the following:

1. Starts creating a new case with a few predefined fields e.g. assignment group.
2. Navigates the user to the newly created record to fill in the remaining details.
3. Allows the user to save the case once details are filled in.

Optimally it would just initialize the case creation once the button is pressed and allow the user to fill in the details, only saving the record once the user presses save.

Is such a thing possible? You can see the button on the dashboard here: 

find_real_file.png

Hope someone can help.

1 ACCEPTED SOLUTION

Arnoud Kooi
ServiceNow Employee
ServiceNow Employee

First, create a page script, and assign it to the click event of the button.

The script content should be something like:

function handler({api, event, helpers, imports}) {
    api.emit('NAV_ITEM_SELECTED', {
        "route": "record",
        "fields": {
            table: "sn_hr_core_case",
            sysId: "-1",
        },
        "params": {
            "query": "short_description=prefill^assignment_group=6816f79cc0a8016401c5a33be04be441"
        }
    });
}

 

View solution in original post

6 REPLIES 6

Arnoud Kooi
ServiceNow Employee
ServiceNow Employee

First, create a page script, and assign it to the click event of the button.

The script content should be something like:

function handler({api, event, helpers, imports}) {
    api.emit('NAV_ITEM_SELECTED', {
        "route": "record",
        "fields": {
            table: "sn_hr_core_case",
            sysId: "-1",
        },
        "params": {
            "query": "short_description=prefill^assignment_group=6816f79cc0a8016401c5a33be04be441"
        }
    });
}

 

I think you could also do this without a script using the link to destination event handler.

Good point, that would be the better solution!

Although it may be likely that a script is needed to determine the dynamic values, like assignment group...

I did try using the destination eventhandler "New case" however the OOB new case page did not work for my purpose. But i guess you could build a new page for the event handler. But, in my case the simplest solution seemed to be the script posted here, so i didnt test that method.