How do you use sys_m2m_template.do?

cbarlock
Kilo Guru

I'm trying to figure out how to use the sys_m2m_template.do slush bucket.  I see from some of the other 'Edit...' UI actions, that many use this:

var uri = action.getGlideURI();
var path = uri.getFileFromPath();
uri.set('sysparm_m2m_ref', current.getTableName());
uri.set('sysparm_stack', 'no');
action.setRedirectURL(uri.toString('sys_m2m_template.do'));

(Not sure why the "var path" line is there since "path" is never used.)  This didn't work for me at all until I set the "Action name" to "sysverb_edit_m2m".  Now, it redirects to the template, but just sits there "Loading".

I was looking at the Group table, which has a Group Members related list.  I found a Group Members relationship which queries from Users.  This makes sense as a mechanism to load the Available column in the slush bucket, but when I tried it with my tables, it did not load.  Also, it is unclear to me what causes a Save on the slush bucket to load the saved group members into sys_user_grmember. 

What am I missing?

Thanks!

6 REPLIES 6

I'm thinking, though, that my apps behavior is not the same as, say, the group membership.  I created a relationship so that Policy will display the BlueGroups that are available in the Project.  These are the only ones that a user should be able to select -- not all the BlueGroups that are defined everywhere.  

But when I think about group membership, you start with no members in your group, so maybe the Policy relationship needs to be with the m2m table?  This is hurting my brain...

I just ran across another community post that says the m2m table creates a Related List that will work with the Edit... button.  Sure enough, on my Policy table, there is another BlueGroup related list (I wrote one, too) and it works with Edit...!  The only thing is that the slush bucket displays all the BlueGroups.  I really want to limit the choices to the BlueGroups that are defined on the Project.  Is that possible?

Here's that post:

https://community.servicenow.com/community?id=community_question&sys_id=f286b430db231bc023f4a345ca96...