Saturday, June 9, 2018

Know SQL query from entity in D365FO

If we need to find the SQL query from an entity we can create a new query and copy paste the datasource from entity to the new query and write below job to get the SQL query as a string.

class RunnableClasstest
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {   
        query query;

        queryBuildDataSource    qbds;

        ;

        query = new Query(queryStr(querytest));

       info(query.dataSourceNo(1).toString());
    }

}