Hi All,
I am trying to create a display method to display product type field in purchline level. product type field is in EcoResProduct table ,when I checked the table it don’t have any direct relation with Purchline table in the same way Purchline table also don’t have any direct relation with EcoResProduct table. I am unable to find any relation to create any relation to create display method, Kindly guide me.
Thankyou All in advance.
Your can use PurchLine.ItemId to get InventTable and then InventTable.Product to get the EcoResProduct.
Thankyou Martin I will try it as you said
Hi Martin,
I wrote the code as below but it is not showing when I try to add the method to string control in DataMethod option in string control properties that I created in Purchtable form.
public display EcoResProductType productType()
{
Purchline purchline;
InventTable inventTable;
EcoResProduct ecoResProduct;
EcoResProductType ProductType;
select * from purchline
where purchline.ItemId == this.ItemId
join inventTable
where inventTable.ItemId == purchline.ItemId
join ecoResProduct
where ecoResProduct.RecId ==inventTable.Product;
if(ecoResProduct)
{
ProductType = ecoResProduct.ProductType;
}
return ProductType;
}
Thankyou Martin, it is working I changed string control to ComboBox control
I’m assuming you added it to an extension of PurchLine table. The value in Data Method property will look like PurchTable_Your_Extension.productType(). Note that you should use a custom prefix for the method, otherwise you’ll get into a trouble when Microsoft (or someone else forgetting a prefix) will create productType() method.
By the way, your code loads all fields from all three tables, although you need a single field only. Also, you don’t need PurchLine at all. Let’s make it more efficient:
display EcoResProductType productType()
{
EcoResProduct ecoResProduct;
InventTable inventTable;
select firstOnly ProductType from ecoResProduct
exists join inventTable
where inventTable.Product == ecoResProduct.RecId
&& inventTable.ItemId == this.ItemId;
return ecoResProduct.ProductType;
}
Thankyou Martin, I will make the changes as you said