List Choice UI Action on related list - How to rerun server side code

B3N_AU
Tera Guru

Hi,

If you run client and server code for a UI Action on a form. To run the server code after you run the client code. You use 

 

gsftSubmit(null, g_form.getFormElement(), 'action_name');

 

 

If your UI Action is a List choice you need to run 

 

var the_list = GlideList2.get(tablename);
the_list.action(action_id, action_name, sysId);

 

 

All of this is working as expected. What I can't seem to do is run the same UI action from a Related list. I've found that the g_list object is not available for related lists on the form link UI action.

How can this be achieved? I've had a look around and tried various methods but I can't get anything to work?

8 REPLIES 8

@B3N_AU 

then I doubt you can achieve this using that

why not have UI page on that related list UI action?

you tried some approach around it?

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

@B3N_AU 

why not use this workaround?

1) let users select the approval records into related list by selecting the checkboxes

2) let GlideAjax happen and show confirm box

3) if they give OK then you already have the approval record sysId in g_list then pick any 1 sysId and use GlideRecord to query approval table to get the CHG sysId and then query CHG and update the state

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

Thanks for the suggestions Ankur

I've got it working from a list but not a related list.

How do I get the approval record sysId in g_list? From what I've read, it's not available for related lists on the form link UI action?

 

This is where I've gotten a bit confused. I thought that g_list object wasn't available but you could still access GlideListV2 by something like this

function confirmApproval() {
	var tablename = "sysapproval_approver";
	var the_list = GlideList2.get(tablename);
	var selected = the_list.getChecked();
	alert(selected);
}

Again, this is working from a list, just not a related list.

 

Getting the approval record sysId from a related list is the last piece of the puzzle.

Thanks Ben

I had the tablename set incorrectly in the above code. It needed to be "sysapproval_approver.sysapproval" 

 

This was the final logic used for getting the checked items from a related list on the form link action.

var tablename = "sysapproval_approver.sysapproval";
var the_list = GlideList2.get(g_form.getTableName() + '.' + tablename);
var selected = the_list.getChecked();

 

Thanks for your help