How to show the related records under related list

Roxi1
Tera Contributor

we have to create a related list on service offering records, under this related list we have to show related "Plans" via plan asset records.

here we have a common field "item" in service offering and plan asset tables. plan asset record has 'plan' field. based on this we will find the related plan records to the current service offering records. 

we have created related list like Applies to table : service_offering

and Queries from table : plan_asset

current.addQuery('item',parent.sys_id); // querying to get the associated plan assets based on item field in current parent record.

but how we have to get plan records from related plan asset records. we have plan field in plan asset records 

1 ACCEPTED SOLUTION

@Roxi1 

That is exactly what my last response is doing. The screens shows exactly that: a service offering shows the related plans (connected through assets). 
Have you tried what I proposed?


If I helped you with your case, please click the Thumb Icon and mark as Correct.


View solution in original post

4 REPLIES 4

Sebas Di Loreto
Kilo Sage
Kilo Sage

@Roxi1 

So what you are creating is called a "Relationship" element.

SebastianDL_0-1674231896398.png

 

As far as I understand you have the "connection" between service_offering and plan_asset done through the item field.

I don't have the plan_asset table in my developer instance but I am installing the "Business Continuity" plugin where I think that table is.

Anyway, you should be creating the "relationship" element on the "plan asset record" table (not the plan_asset) since that is what you want to show on the service_offering record as a related list. Then the script should do the complicated daisy chain to connect the "plan asset record" to the service_offering.

 


If I helped you with your case, please click the Thumb Icon and mark as Correct.


@Roxi1 

I think I got it.

Create this relationship

SebastianDL_0-1674235289795.png

 

Then go to the Service Offerings form and add the "Related Plans" related list.

SebastianDL_1-1674235330383.png

I added my "Test SO" service offering to two plans (as plan asset) and it displays like this. Modify the columns on the "Related plans" related list (in reality is a relationship) to remove what it doesn't add value.

 

SebastianDL_2-1674235402580.png

 

 

 


If I helped you with your case, please click the Thumb Icon and mark as Correct.


Thanks for the response @Sebas Di Loreto 

this relationship queries from "plan" table, and applies to service_offering table 

we have to display the plan records, as ia said before "item" field is the common for service offering and plan asset tables. plan asst records contains plan field which is reference to plan records.

so we have to get displayed the plan records on the service offering table with the help of plan asset.

here is the sample script we tried but no luck

var pln = new GlideRecord('sn_bcp_plan_asset');
pln.addQuery('item',parent.sys_id);
pln.query();
while(pln.next()){
current.addQuery('plan',pln.plan);
current.query();

@Roxi1 

That is exactly what my last response is doing. The screens shows exactly that: a service offering shows the related plans (connected through assets). 
Have you tried what I proposed?


If I helped you with your case, please click the Thumb Icon and mark as Correct.