The CreatorCon Call for Content is officially open! Get started here.

Multiple Onclick Functions - UI Action

Andrew Parkes
Tera Expert

Hi all,

 

Is it possible to have multiple onClick functions in a UI action? 

E.g:

resolveIncident(); copyAttachments()
1 ACCEPTED SOLUTION

Hi,

You don't need to add the function into the UI Client Script, you just need to call it.

function myFunctionSubmit(){
	var x = $$('.attachment_checkbox[value=true]'); //array of the checkbox elements
	if(x.length == 0)
	{
		alert("Please select an attachment");
		return false;
	}
	else if (x.length > 0)
	{
		var list_of_attchs_ids = '';
		var attch_name  = '';
		for (var j=0; j< x.length; j++) {
			//get the sys_id of the attachment from the checkbox element name
			attch_name  = x[j].name.split(':');
			if (list_of_attchs_ids=='')
				list_of_attchs_ids = attch_name[1];
			else
				list_of_attchs_ids = list_of_attchs_ids + ','+ attch_name[1];
		}
		var ajax = new GlideAjax("getAttachmentLists");
		ajax.addParam("sysparm_name","updateAttachmentList");
		ajax.addParam("sysparm_attachmentsysid",list_of_attchs_ids);
		ajax.getXMLWait();
	}
	var ticket_id = g_form.getUniqueValue();
	var table_name = g_form.getTableName();
	var newURL = 'email_client.do?sysparm_table=' + table_name + '&sysparm_sys_id='+ ticket_id +'&sysparm_target=' + table_name + '&sys_target=' + table_name + '&sys_uniqueValue=' + ticket_id +
		'&sys_row=0&sysparm_encoded_record='; //build the URL of the email client window
	//alert(newURL);
	popupOpenEmailClient(newURL); //opens the email client
	resolveIncident();
	GlideDialogWindow.get().destroy(); //to automatically close the window
}

function myFunctionCancel()
{
	GlideDialogWindow.get().destroy();
}

View solution in original post

11 REPLIES 11

Very simple indeed! Thank you very much.

You're most welcome ! 😄