Create UI Action in List and Form view

mballinger
Mega Guru

Hello,

I have a quick question. I created a List UI Action. This UI Action uses glideajax and a script include to grab the selected records from incident table and update a record on a different table. My question is, I want to also make this UI action in the Form view. Would I have to create a separate UI Action for the Form view, or is there something I can do to allow it to work on both views?

***EDIT***

 

List UI Action will check selected records

Form UI Action will check current record

Thanks

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage

Try this:

// Call this function from the Onclick field

function myOnClickFunction() {
	
	var SysId;
	
	if (typeof g_sysId != 'undefined' && g_sysId) {
		// if it is a List Context Menu action
		SysId = g_sysId;
	} else if (typeof g_list != 'undefined') {
		// if it is a List Choice action
		SysId = g_list.getChecked();
	} else {
		// if it is a Form action
		SysId = g_form.getUniqueValue();
	}
	
	// convert into an array
	SysId = SysId.split(','); 

	// and loop through the records
	for (var i = 0; i < SysId.length; i++) {

		// do something here...

	}
	
}

View solution in original post

2 REPLIES 2

Slava Savitsky
Giga Sage

Try this:

// Call this function from the Onclick field

function myOnClickFunction() {
	
	var SysId;
	
	if (typeof g_sysId != 'undefined' && g_sysId) {
		// if it is a List Context Menu action
		SysId = g_sysId;
	} else if (typeof g_list != 'undefined') {
		// if it is a List Choice action
		SysId = g_list.getChecked();
	} else {
		// if it is a Form action
		SysId = g_form.getUniqueValue();
	}
	
	// convert into an array
	SysId = SysId.split(','); 

	// and loop through the records
	for (var i = 0; i < SysId.length; i++) {

		// do something here...

	}
	
}

Sorry for the delayed response. This worked! Had to modify my script include a bit, but finally got it working. 

Thanks again!