web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Chain of Command Datas...
Finance forum

Chain of Command Datasource validateWrite method wrapping how to access datasource fields

(0) ShareShare
ReportReport
Posted on by 30
Hello experts,
I am using Method Wrapper on CustTable form for CustTable datasource validateWrite method.
The only thing that I need is to read AccountNum field from the datasource
I found work around, it works, but I guess it is too complex and it should be a way to read table buffer in more elegant way.
Please see my class extension below:
[ExtensionOf(formdatasourcestr(CustTable, CustTable))]
final class AK_CustTableDataseource_Extension
{
    public boolean validateWrite()
    {
        boolean ret;
        AK_SOCompliance objAK_SOCompliance;
        SalesTable objSalesTable;
        CustTable objCustTable;
        ret = next validateWrite();
        if (ret)
        {
//Here is the portion I don't like BEGIN
           FormRun formRun=this.formRun();
           Common cmn = formRun.dataSource(1).cursor();
            if (cmn is CustTable)
            {
                objCustTable = cmn;
                //if (CustTable.AccountNum == '')
                if (objCustTable.AccountNum != '')
//Portion I don't like END
                {
                    select firstOnly objAK_SOCompliance
                join * from objSalesTable order by objSalesTable.CreatedDateTime desc
                where
                objAK_SOCompliance.SalesId==objSalesTable.SalesId
                && objSalesTable.CustAccount==objCustTable.AccountNum;
           
                    if (objAK_SOCompliance.SalesId)
                    {
                        info("Compliance record for recent Sales Doc: " +
                    objAK_SOCompliance.SalesId + ' ' + objAK_SOCompliance.Compliance);
                    }
                    else
                    {
                        info("No compliance record");
                    }
                }
            }
        }
        return ret;
    }
}
I have the same question (0)
  • Verified answer
    Joris dG Profile Picture
    17,782 on at

    this.cursor() ?

  • Verified answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

       Your formdatasource is this . so below statement should work.      

    FormdataSource  Fds = this;
    
    Custtable custtable= fds.cursor();


  • Verified answer
    Andrew Karasev Profile Picture
    30 on at

    Sukrut,

    Appreciated!  Works

    Andrew

  • Suggested answer
    Andrew Karasev Profile Picture
    30 on at

    Joris,

    This is it, appreciated!

    Andrew

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans