Display Info MSG on CHG request formwhen change tasks are active

praveen47
Tera Contributor

Hi All, 

 

I have a requirement change request have any active change tasks are presented in related list tab, need to display info message on Change form. 

 

I have written the below scripts, when checked using logs it is getting always return false.

Can some one help me on this.

Script Inlcude:

//  Display info message
	checkimpTask: function(parentChg) {
        var answer;
        var chgTask = new GlideRecord("change_task");
        chgTask.addQuery("change_request", parentChg);		
        chgTask.addQuery("change_task_type", "planning");
        chgTask.addQuery("active", "true");
        chgTask.query();
        if (chgTask.next()) {
			
            answer = 'true';
	} 
        return answer;
		
    },

 Client script:

Onload

table: change

function onLoad() {
    //Type appropriate comment here, and begin script below
    var cTask = new GlideAjax('StdChangeTaskUtils');
    cTask.addParam('sysparm_name', checkimpTask);
    cTask.getXML(chgTask);
}
function chgTask(response) {
    var Validation = response.responseXML.documentElement.getAttribute('answer');
    if (Validation == 'true') {
        g_form.showFieldMsg('Display comments');

    }
}

 

Thanks,

Praveen D.

 

2 ACCEPTED SOLUTIONS

Sandeep Rajput
Tera Patron
Tera Patron

@praveen47 Please update your script include as follows.

//  Display info message
	checkimpTask: function() {
        var answer;
        var parentChange = this.getParameter("sysparm_parent_change"); 
        var chgTask = new GlideRecord("change_task");
        chgTask.addQuery("change_request", parentChange);		
        chgTask.addQuery("change_task_type", "planning");
        chgTask.addQuery("active", "true");
        chgTask.query();
        if (chgTask.next()) {
			
            answer = 'true';
	} 
        return answer;
		
    },

Make sure that the script include has Client Callable checkbox checked.

 

Update the client script as follows.

function onLoad() {
    //Type appropriate comment here, and begin script below
    var cTask = new GlideAjax('StdChangeTaskUtils');
    cTask.addParam('sysparm_name', 'checkimpTask');
    cTask.addParam('sysparm_parent_change',g_form.getUniqueValue());
    cTask.getXML(chgTask);
}
function chgTask(response) {
    var Validation = response.responseXML.documentElement.getAttribute('answer');
    if (Validation == 'true') {
        g_form.showFieldMsg('Display comments');

    }
}

 

Hope this helps.

 

View solution in original post

piyushsain
Tera Guru
Tera Guru

you did not send the Parent Change sys_id in OnLoad Client script, add the sys_id in parameter in Glide Ajax and retrieve the parameter in Client callable script Include

 

Script Include:

//  Display info message
	checkimpTask: function() {
        var parentChg = this.getParameter('sysparm_parentChange');
        var answer;
        var chgTask = new GlideRecord("change_task");
        chgTask.addQuery("change_request", parentChg);		
        chgTask.addQuery("change_task_type", "planning");
        chgTask.addQuery("active", "true");
        chgTask.query();
        if (chgTask.next()) {
			
            answer = 'true';
	} 
        return answer;
		
    },

 Client script:

Onload

table: change

function onLoad() {
    //Type appropriate comment here, and begin script below
    var cTask = new GlideAjax('StdChangeTaskUtils');
    cTask.addParam('sysparm_name', checkimpTask);
   cTask.addParam('sysparm_parentChange', g_form.getUniqueValue());
    cTask.getXML(chgTask);
}
function chgTask(response) {
    var Validation = response.responseXML.documentElement.getAttribute('answer');
    if (Validation == 'true') {
        g_form.showFieldMsg('Display comments');

    }
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

View solution in original post

5 REPLIES 5

Vaibhav127
Tera Guru

Hi Praveen,

 

Create a client callable script include and pass the change request sys id from the client script.

Make the following changes,

in the script include change

 

chgTask.addQuery("change_request", this.getParameter('sysparm_change_id'));	

 

in the client script add

 

cTask.addParam('sysparm_change_id', g_form.getUniqueValue());

 

 

Sandeep Rajput
Tera Patron
Tera Patron

@praveen47 Please update your script include as follows.

//  Display info message
	checkimpTask: function() {
        var answer;
        var parentChange = this.getParameter("sysparm_parent_change"); 
        var chgTask = new GlideRecord("change_task");
        chgTask.addQuery("change_request", parentChange);		
        chgTask.addQuery("change_task_type", "planning");
        chgTask.addQuery("active", "true");
        chgTask.query();
        if (chgTask.next()) {
			
            answer = 'true';
	} 
        return answer;
		
    },

Make sure that the script include has Client Callable checkbox checked.

 

Update the client script as follows.

function onLoad() {
    //Type appropriate comment here, and begin script below
    var cTask = new GlideAjax('StdChangeTaskUtils');
    cTask.addParam('sysparm_name', 'checkimpTask');
    cTask.addParam('sysparm_parent_change',g_form.getUniqueValue());
    cTask.getXML(chgTask);
}
function chgTask(response) {
    var Validation = response.responseXML.documentElement.getAttribute('answer');
    if (Validation == 'true') {
        g_form.showFieldMsg('Display comments');

    }
}

 

Hope this helps.

 

piyushsain
Tera Guru
Tera Guru

you did not send the Parent Change sys_id in OnLoad Client script, add the sys_id in parameter in Glide Ajax and retrieve the parameter in Client callable script Include

 

Script Include:

//  Display info message
	checkimpTask: function() {
        var parentChg = this.getParameter('sysparm_parentChange');
        var answer;
        var chgTask = new GlideRecord("change_task");
        chgTask.addQuery("change_request", parentChg);		
        chgTask.addQuery("change_task_type", "planning");
        chgTask.addQuery("active", "true");
        chgTask.query();
        if (chgTask.next()) {
			
            answer = 'true';
	} 
        return answer;
		
    },

 Client script:

Onload

table: change

function onLoad() {
    //Type appropriate comment here, and begin script below
    var cTask = new GlideAjax('StdChangeTaskUtils');
    cTask.addParam('sysparm_name', checkimpTask);
   cTask.addParam('sysparm_parentChange', g_form.getUniqueValue());
    cTask.getXML(chgTask);
}
function chgTask(response) {
    var Validation = response.responseXML.documentElement.getAttribute('answer');
    if (Validation == 'true') {
        g_form.showFieldMsg('Display comments');

    }
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

@praveen47 if my answer also works for you please mark my answer as accepted too

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain