Wednesday, December 27, 2023

using SQL Query in X++

 If you need to execute sql query inside your X++ code then below example can help you. To pass value to SQL query we need to use strfmt() function. 


       str sql;

       Connection conn;

       SqlStatementExecutePermission permission;

       ;


       sql= strFmt("update ProdBOM set InventDimId = '%1' where RecId = %2",                                                                   inventDim.inventDimId,ProdBOM.RecId);

       permission = new SqlStatementExecutePermission(sql);

       conn = new Connection();

       permission = new SqlStatementExecutePermission(sql);

       permission.assert();

       conn.createStatement().executeUpdate(sql);

      

       CodeAccessPermission::revertAssert();

No comments:

Post a Comment

Get Enum Id and Enum Value in D365FO using SQL and X++

 Below is the sql get enum id and enum value of a enum in D365 F&O using sql. SELECT   enumidtable . NAME           'Enum Name' ...