related list edit button is not showing correct slushbucket

runtianliu
Kilo Explorer

I have two tables let's say A and B. There is a ralationship table C. A and B is many to many relationship.

I have a related list of B under A's form. But there is no edit button for this related list so I clicked the enable edit. After I clicked the enable edit button, the edit button shows up. However, the slushbucket in the list is not correct. It's showing all the records in table C. I want records from table B actually. How can I fix this?

1 ACCEPTED SOLUTION

Zach Biewend1
Giga Expert

I ran into the exact same issue. I wanted a clean, intuitive solution for my end users. After I created my own many-to-many table and tried creating a custom 'edit' UI action (unsuccessfully) I found this:



http://wiki.servicenow.com/index.php?title=Creating_a_Many-to-Many_Relationship#gsc.tab=0



This is out-of-box functionality and it does all the work for you. You add a 'to' and 'from' table and customize the labels, and the system does all the rest. You need to add a related list (has the same name as the label you assigned, not the '>' separated names that most related lists have) and the Edit button is there. It will open a slushbucket of the A or B records, and the C record is created behind the curtains.



Hope this helps! Took me about a day of dev to stumble across it.


View solution in original post

6 REPLIES 6

Hi @Mudabir , 

 

This is the current documentation for Many to Many Definitions (sys_m2m): https://www.servicenow.com/docs/bundle/vancouver-platform-administration/page/administer/table-admin...

 

The fields on that form aren't always intuitive, so I like to test it out in a PDI first, then once you understand the 'to' and 'from' values, implement in your environment. 

Hello @ZacharyB8622373 @Zach Biewend1 

Creating a relationship in sys_m2m table did not serve me well. I tried all combinations for "From" "To" but the slush bucket, upon pressing "Edit" button, was showing the records from "To" table and records were getting created in a separate table (new m2m table defined in definition).

So I created a record in sys_collection table and it works like a charm.
However, ServiceNow docs mention to not create a record here and use sys_m2m table, so I was hoping if you could tell whether it took the right route. 🙂