Set reference field for parent record when creating a new record from a related list

Marcel H_
Tera Guru

Ok, so I have something that it feels like it should be pretty easy and I feel like I've done it before, but just can't seem to figure it out.

I have extended the Contracts table (ast_contract) to create a new type called Change Orders (u_change_orders). I'm able to add a related list to the Contract form, and clicking New from the related list allows me to create a new Change Order that relates back to the Contract with no issues. What I would like to do though is have a reference field on Change Orders (u_contract) that is automatically filled in with the parent Contract when creating a new Change Order.

I've looked at other similar tables for Contract, specifically Contract Rate Card (fm_contract_rate_card) that does exactly this, but I don't see where this is being set. I'm very sure that I'm just missing something simple since the parent reference is already being made, I just want that to also populate this field on the custom table.

Any help is appreciated, thanks!

1 ACCEPTED SOLUTION

Marcel H_
Tera Guru

Wow.... never mind, there was an OOB Parent Contract field on the table that I missed that is doing exactly what I wanted. I think it's time for a nap or something haha.

View solution in original post

7 REPLIES 7

dvp
Mega Sage
Mega Sage

You might have to look at the related list that is added

find_real_file.png

 

In the above screenshot when I click new it automatically populates the Parent contract field with #9001

That's what I have as well:

find_real_file.png

 

That reference is being made and works well, but wondering what I need to do to also automatically fill in the field on my form with that reference as well, or better yet fill in other reference fields like Vendor as well. I think that it may also be useful to take information from the parent record like number, short description, and set short description on the change order as well (prefill to reduce manual entry to the team using this)

find_real_file.png

Oleg
Mega Sage

Try to open sys_ui_related_list table and to find Default view of your table. Then to open the sys_ui_related_list_entry table and to fill the filter to some value using "is" (=) operator. Try to use "New" button after the modification. You will see that one can fill values of fields in the way.

I'm not sure that the way can be used in your scenario. Thus you can use another way. You can examine UI Actions of the table displayed in the related list. If you will don't find "New" UI Action then "New" action of the Global table will be used. You should open UI action, which has comment "Related Lists" and the following condition

current.canCreate()&&!RP.getListControl().isOmitNewButton()&&RP.isRelatedList()&&!RP.isManyToMany()&&!RP.isInDevStudio()

It's UI action which works currently. You can copy the code and create new UI action directly on the destination table. You can copy all code and properties (especially the action name "sysverb_new") and then modify it. It could be helpful to examine the code of other records in sys_ui_action table, which has sysverb_new as the Action name and the comment "Related Lists" (the comment isn't required and one should better filter by condition, but usage of the comment "Related Lists" should be enough to find some examples).

Thanks for the suggestions. I took a look at the New UI Action and probably could modify it for that table specifically, but also made me wonder where the parent record relationship is recorded and used in other tables that also use the OOB global New UI Actions.

As an example if I create a new Contract Rate Card (fm_contract_rate_card) record, there is a field on the rate card "contract" that fills in automatically with the parent contract number, but I don't see any BRs, Client Scripts or otherwise that are setting that value, and the dictionary for that field doesn't seem to have any special configuration either.

find_real_file.png

This also happens when creating a Purchase Order from a related list and the Contract field on that form is also filled in automatically.

Is there a place where the parent relationship is recorded and can be accessed to set values?