Wednesday, November 19, 2025

Filter Attachments Docuref when attachments are attached from standard and through custom

 [ExtensionOf(formDatasourceStr(DocuView,DocuRef))]

final class DaxDocuViewForm_Extension
{
    void initValue()
    {
        DocuRef      docuref;
        next initvalue();
        //Args args = element.args();
        //PurchTable     purchtable = args.record();
        if(element.args().menuitemname() == menuitemdisplaystr(Dax_VendorattachmentMenuitem))
        {
            docuref.DAX_NoYes = NoYes::Yes;
        }
        else
        {
            docuref.DAX_NoYes = NoYes::No;
        }
    }
}


and in Docuhistory:-

internal final class Dax_DocuHistoryTable
{

    [DataEventHandler(tableStr(DocuHistory), DataEventType::Inserted)]
    public static void DocuHistory_onInserted(Common sender, DataEventArgs e)
    {
        DocuHistory docuHistory = sender as DocuHistory;
        DocuHistory docuHistoryloc;
        DocuRef     docuRef;
        if(docuHistory.DocuValueDeleted==NoYes::No)
        {
            if (!docuHistory)
            return;

 

            select firstonly docuRef
                where docuRef.RecId == docuHistory.DocuRefRecId;

 

                if (docuRef)
                {
                    ttsbegin;
                    docuHistory.selectForUpdate(true);
                    docuHistory.Dax_IsCustomAttachment = docuRef.DAX_NoYes;
                    docuHistory.update();
                    ttscommit;
                }
        }
        else
        {
            if (!docuHistory)
            return;
            select firstonly docuHistoryloc
                where docuHistoryloc.DocuRefRecId==docuHistory.DocuRefRecId
&& docuHistoryloc.DocuValueDeleted==NoYes::No;
            ttsbegin;
            docuHistory.selectForUpdate(true);
            docuHistory.Dax_IsCustomAttachment =docuHistoryloc.Dax_IsCustomAttachment;
            docuHistory.update();
            ttscommit;

 

        }
    }

 

}

No comments:

Post a Comment

Filter Attachments Docuref when attachments are attached from standard and through custom

 [ExtensionOf(formDatasourceStr(DocuView,DocuRef))] final class DaxDocuViewForm_Extension {     void initValue()     {         DocuRef ...