logo

NJP

"View Data to Preserve" Tool

Import · Oct 20, 2018 · article

Included in the Developer Toolbox Update Set available on Share (link to Share in the post).

Continuing my theme of helpful features ("GlideRecord Script" Tools, "Grab Group Information" Tool), I present the "View Data to Preserve" Related Links UI Action:

image

I've been working with the System Clone Application quite a bit lately and developed this in order to confirm the data that would be returned by the Conditions query built in the Clone Data Preserver form. Clicking on the link will open up a new tab/window with the results of the query:

image

Here are the UI Action details:

Name: View Data to Preserve

Table: Clone Data Preserver [clone_data_preserver]

Order: 100,000

Action name: u_fpc_view_data_to_preserve

Active: Checked

Show insert: Checked

Show update: Checked

Client: Checked

Form link: Checked

Hint: Open list of records matching the current condition filter in a new tab/window (FPC)

OnClick: uFpcViewDataToPreserve();

Condition: current.canRead();

Messages: u_fpc_view_data_to_preserve.select.table

Script:

function uFpcViewDataToPreserve(){

    //hide any previous field messages
    try {
        g_form.hideFieldMsg("table", true);
    } catch(err) {}

    //get the selected table
    var table = g_form.getValue("table");

    if (table != "") {
        //we want to see a list view of the table
        var gUrl = new GlideURL(table + "_list.do");

        //has a condition been set?
        var condition = g_form.getValue("condition");
        if (condition != "") {
            //add it to the URL
            gUrl.addParam("sysparm_query", condition);
        }

        //then open a new tab/window
        g_navigation.open(gUrl.getURL(), "_blank");
    } else {
        g_form.showFieldMsg("table", getMessage("u_fpc_view_data_to_preserve.select.table"), "warning");
    }
}

I've attached XML files for the UI Action and UI Message records so you can just import them into your instance. As always, try it out in your company's development instance first, or better yet, your own personal development instance.

View original source

https://www.servicenow.com/community/developer-blog/quot-view-data-to-preserve-quot-tool/ba-p/2266408