Skip to main content

Notifications

Community site session details

Community site session details

Session Id :

X++ code to whether given view exists or not using SQLBuilder class(es) in D365FO

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

In this post will provide the code to check if concerned/given view exists in D365FO or not and for this purpose we are making use of SQLBuilderView class. Trying to check if the view by name Customer exists or not.

Note: CG_DoesViewExistsUsingSQLBuilder  is a runnable class.
class CG_DoesViewExistsUsingSQLBuilder
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {     
        SQLBuilderViewNavn  viewId = viewstr(Customer);
        boolean             doesViewExists;
        doesViewExists = SQLBuilderView::viewExist(viewId);
        if (doesViewExists == true)
        {
            Info(strFmt("View %1 exists", viewId));
        }
        else
        {
            Info(strFmt("View %1 not exists", viewId));
        }
    }
}

Output

Regards,

Chaitanya

Comments

*This post is locked for comments