Number of Attachments Indicator in Dynamics AX 2012
I have been asked by a couple of customers to add a number indicator on the attachments button in AX 2012. The idea being when a user opens a form, like the sales order form, they can look at the number on the attachments button and tell right away if there are any attachments on the sales order. This is very similar to a cue but you cannot use a cue on a button so you have to find a different way to do it. Here is what I did on the SalesQuotationTable form.
1. On the form you want to modify, in the active method on the datasource, change the text on the button to something like:
Attachments.text(int642str(SalesQuotationTable.getNumOfAttachments()) + "\n" + "@SYS316708");
2. Create the method: getNumOfAttachments on the SalesQuotationTable or datasource on the form.
display int64 getNumOfAttachments()
{
DocuRef docuRef;
select count(RecId)
from docuRef
where docuRef.RefCompanyId == this.DataAreaId
&& docuRef.RefTableId == this.tableId
&& docuRef.RefRecId == this.RecId;
return docuRef.RecId;
}
Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.
Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.