- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 05:30 AM
Hi All,
We have two tables Table A & Table B.. Need to have related list on Table A and on the Related list need to create Button as "Create Record", which need to redirect to Table B form and also need to prepopulate some of the fields data by pulling the value from the current Table A record.
Please help to achieve this..
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 05:57 AM
Hello ,
For this you need to have a reference field on table A which will be referring to table B then after creating the reference field you need to right click on form banner and do configure related list and then pull the related list with table name as your Table B.
You can create a UI action on table B and create it at the list level but not on the form level by checking the check box "List banner button"
and you can write the code in the table B UI action script to redirect the user to new record of table b
gs.setRedirectURL('/your_table_b_name.do?sys_id=-1'); // to redirect to a new record
To auto populate you need to glide record to table A with the field which is referring to table B and put the code in on before business rule so that it auto populates before the form loads
configure your BR on table B
var gr = new GlideRecord('table a');
gr.addQuery('your field which is referring to table B',current.sys_id);
gr.query();
if(gr.next())
{
gr.your_field_name = current.your field name to be auto populated
}
please mark this helpful if it answers your question
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 05:57 AM
Hello ,
For this you need to have a reference field on table A which will be referring to table B then after creating the reference field you need to right click on form banner and do configure related list and then pull the related list with table name as your Table B.
You can create a UI action on table B and create it at the list level but not on the form level by checking the check box "List banner button"
and you can write the code in the table B UI action script to redirect the user to new record of table b
gs.setRedirectURL('/your_table_b_name.do?sys_id=-1'); // to redirect to a new record
To auto populate you need to glide record to table A with the field which is referring to table B and put the code in on before business rule so that it auto populates before the form loads
configure your BR on table B
var gr = new GlideRecord('table a');
gr.addQuery('your field which is referring to table B',current.sys_id);
gr.query();
if(gr.next())
{
gr.your_field_name = current.your field name to be auto populated
}
please mark this helpful if it answers your question
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2022 06:05 AM
Hi,
So does the Table B have any field which refers to Table A?
If yes then the related list will be available. It's just that you need to add it via Configure -> Related list on form
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader