How to add main record number when clicking new on related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2022 07:22 AM
Hello everyone,
I will greatly appreciate the help in this case/scenario.
I have three tables, one main table to add items, a second table to add qa for items, and an m2m table to link both tables with a multiple to multiple relationship. When I click new on the related list of a record I will like to auto populate the glide list field with the main record number on each table(items and qa). I have tried with a business rule to perform this but it is not doing it.
Also each form has a glide list that gets populated with related records that are selected from related list. This is working through another business rule I created on the m2m table.
Below is what I have tried to get the new related record opened with qa main record on the glide list field (qa records).
Business rule is done on the m2m table on insert only running after.
var gr = new GlideRecord('items_table_name');
gr.addQuery();
gr.query();
While (gr.new()) {
gr.setValue(qa_record.number)//here it should populate glide list field on items table with the qa new record.
}
Hope this makes sense. Will greatly appreciate your collaboration.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 05:12 PM
If I understand correctly, you are trying to create a new record and associate them via m2m at the same time. The m2m won't be able to associate records until they have been saved and have their updated sys_id (not -1.)
I think one option is to split this out into two parts:
- Create a new UI Action that overrides the original New button that directs to the new form and populates the field you want to have the item in.
- Have a business rule that runs on the qa table so when the new record is inserted and if the item reference is not blank, it creates the m2m record associating the item and qa records.