Help with Scripting a Relationship

Su522
Kilo Sage

In Order Management: 

How can I script a Relationship from the 'Oder Line Item' to the 'Product Order'?

System Defenition > Relationships

Order Line Item: sn_ind_tmt_orm_order_line_item

Product Order: sn_ind_tmt_orm_product_order 

Field on Order Line Item table: order_line_item

Field on Product Order Table: number

See attached.

 

I need to create a Related List on the Product Order table that displays the associated Order Line Items.

Greatly appreciate help!!!

Thank you

 

 

1 ACCEPTED SOLUTION

No worries @Su522,

 

I see, so you want to show all the Order Line Items under the same Order. I don't have much experience with Order Management but I don't think this is how you should be using it. An Order Line Item should be linked to a Product Order and the PO shouldn't be shared across multiple OLIs.

JamesChun_0-1711074031837.png

 

But once again, you can use the below script:

 

(function refineQuery(current, parent) {
    current.addEncodedQuery('order=' + parent.order_line_item.order);
})(current, parent);

Cheers

View solution in original post

7 REPLIES 7

James Chun
Kilo Patron

Hey @Su522,

 

Is there a need to create a related list here? The reference record to the Order Line Item is already there, so you can use that to show dot-walked fields on the form instead of creating a related list.

 

If you do need to create a new related list, you can use the script below:

(function refineQuery(current, parent) {
    current.addEncodedQuery('sys_id=' + parent.order_line_item);
})(current, parent);

 

Cheers

 

 

@James Chun 

Yes, we need the Related List because there are several 'Order Line Items' associated with a 'Product Order'

That field on the 'Product Order' form only displays 1 of the 'Order Line Items' and we will probably be removing it from the form, (since it is misleading- as there are several 'Order Line Items' that are assoicated with a 'Product Order'.

Your code worked, however it only displays 1 'Order Line Item' (the one in that field) in the Related List. 

So I dont think we can use "parent" for this purpose? We need to get all associcatd 'Order Line Items' to show in the Related List on the 'Product Order form.

See screenshots (with descriptions in the title)

 

I really appreciate your help!!!

Thakn you

No worries @Su522,

 

I see, so you want to show all the Order Line Items under the same Order. I don't have much experience with Order Management but I don't think this is how you should be using it. An Order Line Item should be linked to a Product Order and the PO shouldn't be shared across multiple OLIs.

JamesChun_0-1711074031837.png

 

But once again, you can use the below script:

 

(function refineQuery(current, parent) {
    current.addEncodedQuery('order=' + parent.order_line_item.order);
})(current, parent);

Cheers

@James Chun 

You are AWESOME!!!! That worked!!

Thank you so much!!!