In this blog i will show you how to bypass or disable extensible data security (xds) policy on runtime in Dynamics AX 2012 and Dynamics 365 for Finance and Operations.
The scenario is to get all records of warehouse on lookup which is already filtered through applied XDS on user.
AX2012
XDSServices xdsService = new XDSServices(); xdsService.setXDSState(0); SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventLocation), _ctrl); Query query = new Query(); QueryBuildDataSource queryBuildDataSource; queryBuildDataSource = query.addDataSource(tableNum(InventLocation)); sysTableLookup.addLookupfield(fieldNum(InventLocation, inventlocationid)); sysTableLookup.addLookupfield(fieldNum(InventLocation, Name)); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup();
Dynamics 365 for Finance and Operations
unchecked(uncheck::XDS) { SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(InventLocation), _ctrl); Query query = new Query(); QueryBuildDataSource queryBuildDataSource; queryBuildDataSource = query.addDataSource(tableNum(InventLocation)); sysTableLookup.addLookupfield(fieldNum(InventLocation, inventlocationid)); sysTableLookup.addLookupfield(fieldNum(InventLocation, Name)); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }
Thanks,
Happy Coding
*This post is locked for comments