This is the solution I use, it shows if documents are attached to a specific vendor.
On the table you want to attach the doc, add a method as following (I used vendtable in my example, just modify according your requirements):
display smmDocIconNum ShowDoc()
select VendTable where VendTable.AccountNum == this.AccountNum;
if ((select docuRef //table that stores documents in AX
where docuRef.RefCompanyId == this.DataAreaId &&
docuRef.RefTableId == tablenum(VendTable) &&
docuRef.RefRecId == VendTable.RecId).RecId)
return #RES_NODE_DOC; // returns a book icon if a doc is found for the selected record
return #RES_AM_NEW; // returns a blank page when no doc is found
You have to be very specific on the select, it must return one record.
then on the corresponding form, add a window control on grid lines, set the above method as datasource, it will show if there’s documents attached on the record by showing a book or blank page.
then last step, add a mouseup() or mouseDblClick() method on the icon field you added before with the following code:
int mouseUp(int _x, int _y, int _button, boolean _ctrl, boolean _shift)
ret = super(_x, _y, _button, _ctrl, _shift);
if (VendTable && VendTable.RecId && _button == #leftClick)
this will open the Docuref form filtered on the document corresponding to your record or blank form if there’ no doc.
mail me if you have more specific questions.
Hope it helps, please verify solution if it solves your problem