Display the attachment for the item in a new form

Hi Guys,

I want to display the attachment for the ecoresproduct(Products) to the new form.I not seen relation between ecoresproduct to docuref table.Can anyone tell how to display the attachment for the products in the form

It is same for all the table,

docuRef.RefTableId == ecoresproduct.tableId
&& docuRef.RefRecId == ecoresproduct.RecId

If you are looking for product images, then there is a separate table for that. EcoResProductImage

Moving to developer forum. Please post development related questions in the developer form but not in the user forum.

Hi kranthi,

I have written this code in the form init method but data is not filter as per relation

public void init()

{

DocuRef _docuRef;
EcoResProduct _ecoResProduct;
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds,qbds1;

;

query = new Query();

qbds1= query.dataSourceTable(tableNum(DocuRef)).addDataSource(tableNum(EcoResProduct));
qbds1.addLink(fieldNum(DocuRef,RefTableId),fieldNum(EcoResProduct,TableId));
qbds1.addLink(fieldNum(DocuRef,RefRecId),fieldNum(EcoResProduct,RecId));
qbds1.addLink(fieldNum(DocuRef,RefCompanyId),fieldNum(EcoResProduct,DataAreaId));

queryRun = new QueryRun(query);

while(queryRun.next())
{
_docuRef = queryRun.get(tableNum(DocuRef));
_ecoResProduct = queryRun.get(tableNum(EcoResProduct));
}

}

What is your form data source?

Try joining the EcoResProduct with your query data source.

query = DocuRef_ds.query();

Properly adding the link between form Data source and EcoResProduct is enough, you don’t have to run the query.

You may not need this link, as EcoResProduct is not a company specific table.

i have done it in Ax 2012 R3 at Purchase Order level… may be it will be helpful for you.

i just write code in PurchaseForm like

public void showImage()
{
Image itemImage;
RecId productImageRecId;
EcoResProductImage ecoResProductImage;
container containerimage;
productImageRecId = InventTable::find(PurchLine.ItemId).RecId;//5637151790;

if(productImageRecId)
{
select ecoResProductImage where ecoResProductImage.RefRecId == productImageRecId
|| ecoResProductImage.RefRecord == productImageRecId;

containerImage = ecoResProductImage.ThumbnailSize;

itemImage = new Image();
itemImage.setData(containerImage);
Image.image(itemImage);
image.widthValue(itemImage.width());
image.heightValue(itemImage.height());
}
and then i called this method active metod of purch Table in form dataSource…

i.e elment.showimage(); and its working fine…

May be it is not useful for you but you can get idea from my code…

i have done it , and when user create new PO from that item so attachment will show … but in Ax 2012 R3.

i just create method at form level and call that method active datasource purchTable at form level…

i.e

public void showImage()
{
Image itemImage;
RecId productImageRecId;
EcoResProductImage ecoResProductImage;
container containerimage;
productImageRecId = InventTable::find(PurchLine.ItemId).RecId;//5637151790;

if(productImageRecId)
{
select ecoResProductImage where ecoResProductImage.RefRecId == productImageRecId
|| ecoResProductImage.RefRecord == productImageRecId;

containerImage = ecoResProductImage.ThumbnailSize;

itemImage = new Image();
itemImage.setData(containerImage);
Image.image(itemImage);
image.widthValue(itemImage.width());
image.heightValue(itemImage.height());
}
and then i called this method active metod of purch Table in form dataSource…

i.e element.showimage()

Hi kranthi,

I have added two datasource in the form.

1.Docuref

2.Ecoreproduct

I have added below code in the form init method

public void init()
{

Query query;
QueryBuildDataSource qbds,qbds1;
;
query = DocuRef_ds.query();

qbds1= query.dataSourceTable(tableNum(DocuRef)).addDataSource(tableNum(EcoResProduct));
qbds1.addLink(fieldNum(DocuRef,RefTableId),fieldNum(EcoResProduct,TableId));
qbds1.addLink(fieldNum(DocuRef,RefRecId),fieldNum(EcoResProduct,RecId));

}

Now as relation no of records filter in grid but ecoresproduct field records are showing empty.i have refresh the datasource but ecoresproduct field value is not displayed in the form grid.

Don’t add the data source again.

What is JoinSource and LinkType on EcoRedProduct?

qbds1 = DocuRef_ds.query().dataSourceTable(tableNum(EcoResProduct));
qbds1.joinMode(JoinMode::InnerJoin);

qbds1.addLink(fieldNum(DocuRef,RefTableId),fieldNum(EcoResProduct,TableId));
qbds1.addLink(fieldNum(DocuRef,RefRecId),fieldNum(EcoResProduct,RecId));