Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Action and emailClientOpenPop

ashish9
Tera Contributor

I have a button Approval on XYZ form.

 

If I click on Approval button while Client is selected and onClick event as emailClientOpenPop('sc_task');  it open the Email Pop up perfectly.

 

But if I unchecked Client it hide the onClick option and I can change the current.u_status = 'Close'; on the XYZ form.

 

But actual requirement is both think Email Client Pop up and the status update should happen simultaneously.  

 

So is it possible I can call Email Client pop up from script and at the same time it updates the status.

 

Thanks

1 ACCEPTED SOLUTION

Hi,

Script looks good.

Did you try adding logs in script include

var UpdateRecord = Class.create();
UpdateRecord.prototype = Object.extendsObject(AbstractAjaxProcessor, {

updateMyRecord: function(){

var sysId = this.getParameter('sysparm_id');

gs.info('sysId' +sysId);
var tableName = this.getParameter('sysparm_table');
var gr = new GlideRecord('XYZ');
gr.addQuery("sys_id", sysId);
gr.query();
if (gr.next()) {

gs.info('Record found');
gr.u_status = 'Approved';
gr.update();
}
},

type: 'UpdateRecord'
});

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

33 REPLIES 33

Thanks Peter, I will check that too

Hi,

Then use GlideAjax and keep the UI action as client side only

UI Action Script:

function validateForm() {

	var ga = new GlideAjax('UpdateRecord');
	ga.addParam('sysparm_name', "updateMyRecord");
	ga.addParam('sysparm_id', g_form.getUniqueValue());
	ga.addParam('sysparm_table', g_form.getTableName());
	ga.getXMLAnswer(function(answer){
		emailClientOpenPop('sc_task');
	});
}

Script Include:

var UpdateRecord = Class.create();
UpdateRecord.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	updateMyRecord: function(){

		var sysId = this.getParameter('sysparm_id');
		var tableName = this.getParameter('sysparm_table');
		var gr = new GlideRecord(tableName);
		gr.addQuery("sys_id", sysId);
		gr.query();
		if (gr.next()) {
			gr.u_status = 'Approved';
			gr.update();
		}
	},

	type: 'UpdateRecord'
});

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks Ankur, I will try this and wll let you know

Any update on this?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, It is not working I am checking if I am missing anything.