How do you use sys_m2m_template.do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2021 01:53 PM
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!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2021 03:21 PM
Are you trying to create a custom m2m / o2m UI action for your table? Have you defined this in the many to many relationship table so the system knows there is a m2m relationship?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2021 03:32 PM
I am...I think. I did not do anything overt to define this as many to many.
What I'm really trying to do is to use the slush bucket functionality you find on the Group table to assign Roles or Group Members. I have a "Project" to which you can add "Policies" and "BlueGroups". For each Policy in the Project I want to select one or more BlueGroups from the Project.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2021 04:27 PM
Ah makes sense,
You should be able to follow this link on how to create a many to many relationship. This'll allow the native "Edit..." button to work without needing to do any modifications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2021 06:33 AM
I created the m2m relationship, but the template page just sits with Loading. I don't think it matters, since this is a m2m relationship, but when it didn't work the first time, I swapped the from and to tables. That didn't help.