Aborting message through UI Action

abirakundu23
Giga Sage

Hi All/ @Sandeep Rajput ,

Actually, want to show abort message when click on "UI Action".

We have called script include from server side, so that we have put condition in UI action condition.

As per script logs are executed but taking wrong record value.

Script include:

var Test = Class.create();
Test.prototype = {
    initialize: function() {
    },
    validation:function(){
var checkstatus = false;
gs.info("Checking issue >>> Line6");
var caserecord = new GlideRecord('sn_hr_core_case');
caserecord.addEncodedQuery('u_test=Yes^active=true');
gs.info("Checking issue >>> Line9");
caserecord.query();
gs.info('Checking the issue case record');
if(caserecord.next())
{
    //var taskrecord = new GlideRecord('sn_hr_core_task');
    //taskrecord.addQuery('parent',current.parent.sys_id);
    gs.info('Checking the validation issue case record');
    var count = 0;
    var case_record=caserecord.sys_id;
    gs.info('case record:' +case_record);
    var task_table = new GlideAggregate('sn_hr_core_task');
    var temp = gs.getProperty('sn_hr_core.ValidationTask');
    task_table.addEncodedQuery('template='+ temp +'^parent=' + case_record);
    task_table.addAggregate('COUNT');
    task_table.query();
    while (task_table.next()) {
        count = task_table.getAggregate('COUNT');
    }
    gs.info('Count is'+count);
    while (task_table.next()) {
    if((count == 0 )|| (count !=0 && task_table.state != '3'))
    {
        gs.info("Checking issue");
        current.setAbortAction(true);
        gs.addErrorMessage('Testing info');
    }
    else if(count !=0 && task_table.state == '3'){
    current.setAbortAction(false);
    }
}
       
}

},

    type: 'Validationrestrict'
};
 
This log message throws wrong record id :gs.info('case record:' +case_record);
Could you please suggest?

 

 

6 REPLIES 6

abirakundu23
Giga Sage

Hello @Community Alums ,

Thanks for your response. Looking for change in OOB "Transfer Case" Workspace Client-side script.

Could you please check my yesterday post & suggest me?

abirakundu23
Giga Sage

Hi @Sandeep Rajput ,

We have tried using Workspace client script & called Script include. But its not working.

abirakundu23_0-1718114298963.png

Called client callable Script include:

gs.info("Checking the validation issue");
var Test  = Class.create();
Test.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    validation: function() {
        var checkstatus = false;
        var casesysid = this.getParameter('sysparm_sys_id');
        gs.info("Checking the issue >>> Line6");
        var caserecord = new GlideRecord('sn_hr_core_case');
        caserecord.addEncodedQuery('u_validation_required=Yes^active=true');
        gs.info("Checking the issue >>> Line9");
        caserecord.addQuery('sys_id', casesysid);
        caserecord.query();
        gs.info('Checking the validation issue case record');
        if (caserecord.next()) {

            gs.info('Checking the validation issue case record');
            var count = 0;
            var case_record = caserecord.sys_id;
            gs.info('case record:' + case_record);
            var task_table = new GlideAggregate('sn_hr_core_task');
            var temp = gs.getProperty('sn_hr_core.ValidationTask');
            task_table.addEncodedQuery('template=' + temp + '^parent=' + case_record);
            task_table.addAggregate('COUNT');
            task_table.query();
            while (task_table.next()) {
                count = task_table.getAggregate('COUNT');
            }
            gs.info('Count is' + count);
            while (task_table.next()) {
                if (count == 0) {
                    gs.info("Checking the validation issue");
                   
                    checkstatus = false;
                } else
                    checkstatus = true;

            }

        }
        return checkstatus;
    },

    type: 'ValidationRestrict'
});
Could you please suggest why script include not called &m its not work as expected