- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2023 12:02 PM
Hi Everyone,
I've been doing full stack dev for years but as I dive into ServiceNow there are so many things that happen 'under the hood' that it sometimes eludes me as to what to do. I am sorry if I don't get this immediately but I have a super simple project where there is an initial form (initial_form) to allow people to enter their demographic information (name, address, etc.). After the client fills in the form and submits it, I want to automatically create a separate record in another table (full_details_form) that will have further, more detailed fields (eg. medical history) which will be viewable by the owner only.
So, I thought I'd use the m2m list to help manage that auto-magically. Meaning, the client enters their info on the initial_form, SN automatically creates a record in the full_details_form and links it all nicely in the m2m table. Also, if the client wants to edit some allowable information in their record, will m2m automatically update any references? I'm so confused and I've scoured videos and the SN docs. I'm sorry if this is obvious...
I honestly don't understand how m2m works if it's supposed to help or what it does - perhaps I'm missing just a simple piece of information. In my old work I'd have to create the associative table and use server-side scripting to manage the PK and FK of it all.
Could someone please point me in the right direction...am I asking the right question? should I be using m2m at all? what are the magic advantages it has?
Thank you for your time and help in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 11:54 AM
Y-Developer,
I think you might be combining a couple things. An M2M relationship links things like a Group to multiple users and a User to multiple Groups. When you add a user to a group there is a record created on the M2M table "sys_user_grmember" but creating a User or Group does not automatically create a User or Group record. the sys_m2m record creates a new M2M table for your relationship similar to "sys_user_grmember" table. If you look at the sys_collection table
plug your instance name in link below to go to sys_collection table filtered to sys_user_grmember table.
The sys_collection records are the OOB M2M relationships...It's a confusing because they use two records there but in sys_m2m the one record does the job of both sys_collection records.
In order to have a 2nd record created based on the first you need some sort of automation, Flow, Workflow, Business Rule...
I just realized you might be trying to create your tables with the M2M record?....The tables you're relating need to be created before the sys_m2m record.
Hopefully that's helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 05:02 PM
Glad you got it...you're welcome