Risk assessment button is not working and data is not populating

Pravallika Rach
Tera Contributor

We have Assessment table(assessment).

In change table(change_table) we have reference field which is (assessment_instance) as it is referring to assessment table. 

Now we have main table which is task table in that I have created a UI action with below code.When we click on UI Action it should pop up and the data needs to be visible but it is not working as expected.

 

Please correct me where I have made mistake.

 

UI Action :

function showResponse() {
    var id = g_form.getUniqueValue();
    var type = g_form.getValue('metric_type');
    var a = g_form.getValue('number');

    var inc = new GlideRecord("change_table");
    inc.addQuery("name", "CONTAINS", a);
    inc.query();
    while (inc.next()) {
        var b = inc.getValue("assessment_instance");
    }
    var ass = new GlideRecord("assessment");
    ass.addQuery("number", b);
    ass.query();
    while (ass.next()) {
        var c = ass.getValue("sys_id");
    }
    var url = 'assessment_take.do?sysparm_assessable_sysid=' + b + '&sysparm_assessable_type=' + type + '&sysparm_reader_view=true';

    var d = new GlideOverlay({
        title: getMessage("User's Response"),
        iframe: url,
        width: '80%',
        height: '100%',
        onAfterLoad: function() {
            var iframe = d.getIFrameElement();
            setTimeout(function() {
                iframe.height = parseInt(iframe.height) + 1;
            }, 0);
        }
    });
    d.render();
}

5 REPLIES 5

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Pravallika Rach ,

 

In your code u have used g_form(Client Side) as well as GlideRecord(Server Side).

At a given time UI action can behave either Client Side or Server Side. So with current logic it wont work You need to write ur logic accordingly.

I would suggest keep the Client checkbox checked & in ur code the Glide Record part u can use by calling GlideAjax n writing the GlideRecord logic in the script include. 

 

Thanks,

Danish