Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Using record information displayed in a portal form widget

bonsai
Mega Sage

I've been considering a way to use record information from a form widget displayed on a portal screen to perform client processing in another widget.

I discovered that there is a way to customize the form widget and pass the displayed data to another widget.

I'm reluctant to customize OOTB functionality like the form widget.

Is there a way to obtain information in another widget without damaging the form widget?

I don't need to use the real-time information displayed in the form widget; I would like to implement processing using the displayed record information registered on the server.

Does anyone know how to do this?

1 ACCEPTED SOLUTION

vaishali231
Tera Guru

hey @bonsai 

 

 Yes, you can do it without customizing the OOTB Form widget
The Form widget just displays the record.
Your other widget can simply fetch the same record again from the server using:

URL params: ?table=incident&sys_id=xxxxx
or widget options

This is the recommended + upgrade safe way.

 

 Option 1 : Use URL Parameters
Widget 2 – Server Script

(function() {

    data.table = $sp.getParameter("table");
    data.sys_id = $sp.getParameter("sys_id");

    if (!data.table || !data.sys_id)
        return;

    var gr = new GlideRecord(data.table);
    if (gr.get(data.sys_id)) {

        data.record = {};
        data.record.number = gr.getValue("number");
        data.record.short_description = gr.getValue("short_description");
        data.record.state = gr.getValue("state");
        data.record.sys_id = gr.getUniqueValue();
        data.record.table = gr.getTableName();
    }

})();

 

Widget 2 – Client Script

Api.controller = function($scope) {
    var c = this;

    console.log("Record Number : " + c.data.record.number);
    console.log("Short Desc    : " + c.data.record.short_description);
}


 Option 2: Use Widget Options (If URL doesn’t have sys_id/table)
Widget 2 – Server Script

(function() {

    data.table = options.table;
    data.sys_id = options.sys_id;

    if (!data.table || !data.sys_id)
        return;

    var gr = new GlideRecord(data.table);
    if (gr.get(data.sys_id)) {

        data.record = {};
        data.record.number = gr.getValue("number");
        data.record.short_description = gr.getValue("short_description");
    }

})();

Then  set widget options:

 

 

table = incident

sys_id = xxxxxxxxxxxxxxxx

 

*************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

 

 

View solution in original post

1 REPLY 1

vaishali231
Tera Guru

hey @bonsai 

 

 Yes, you can do it without customizing the OOTB Form widget
The Form widget just displays the record.
Your other widget can simply fetch the same record again from the server using:

URL params: ?table=incident&sys_id=xxxxx
or widget options

This is the recommended + upgrade safe way.

 

 Option 1 : Use URL Parameters
Widget 2 – Server Script

(function() {

    data.table = $sp.getParameter("table");
    data.sys_id = $sp.getParameter("sys_id");

    if (!data.table || !data.sys_id)
        return;

    var gr = new GlideRecord(data.table);
    if (gr.get(data.sys_id)) {

        data.record = {};
        data.record.number = gr.getValue("number");
        data.record.short_description = gr.getValue("short_description");
        data.record.state = gr.getValue("state");
        data.record.sys_id = gr.getUniqueValue();
        data.record.table = gr.getTableName();
    }

})();

 

Widget 2 – Client Script

Api.controller = function($scope) {
    var c = this;

    console.log("Record Number : " + c.data.record.number);
    console.log("Short Desc    : " + c.data.record.short_description);
}


 Option 2: Use Widget Options (If URL doesn’t have sys_id/table)
Widget 2 – Server Script

(function() {

    data.table = options.table;
    data.sys_id = options.sys_id;

    if (!data.table || !data.sys_id)
        return;

    var gr = new GlideRecord(data.table);
    if (gr.get(data.sys_id)) {

        data.record = {};
        data.record.number = gr.getValue("number");
        data.record.short_description = gr.getValue("short_description");
    }

})();

Then  set widget options:

 

 

table = incident

sys_id = xxxxxxxxxxxxxxxx

 

*************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh