This is simple filter code for Binding user to particular office in axapta application. Like current user is adam and you want to show him only one employee date then you can use filter methodology this way.
public void filter1()
{
UserId currentUserId;
SysCompanyUserInfo sysCompanyUserInfo;
_ServiceDetails2 _ServiceDetails2;
EmplTable emplTable;
InventLocationId inventLoc;
Date LastDate;
RecId RecId;
currentUserId = curUserId();
select * from sysCompanyUserInfo
where sysCompanyUserInfo.UserId == currentUserID;
if(sysCompanyUserInfo)
{
if(sysCompanyUserInfo.EmplId != "")
{
select * from emplTable
where emplTable.EmplId == sysCompanyUserInfo.EmplId;
if(emplTable)
{
if(emplTable.EmplId != "")
{
while select * from _ServiceDetails2
where _ServiceDetails2.EmplId == emplTable.EmplId
{
if(LastDate == any2date(0))
{
LastDate = _ServiceDetails2.DateTo;
RecId = _ServiceDetails2.RecId;
}
else
{
if(LastDate < _ServiceDetails2.DateTo)
{ LastDate = _ServiceDetails2.DateTo;
RecId = _ServiceDetails2.RecId; } } }
// if(LastDate != any2date(0))
{ select * from _ServiceDetails2 where _ServiceDetails2.RecId == RecId;
this.query().dataSourceName("_Provision").addRange(fieldnum(_Provision,OfficeName)).value(_ServiceDetails2.Office); } } } } } //super(_field, _value); }
public void filter1()
{
UserId currentUserId;
SysCompanyUserInfo sysCompanyUserInfo;
_ServiceDetails2 _ServiceDetails2;
EmplTable emplTable;
InventLocationId inventLoc;
Date LastDate;
RecId RecId;
currentUserId = curUserId();
select * from sysCompanyUserInfo
where sysCompanyUserInfo.UserId == currentUserID;
if(sysCompanyUserInfo)
{
if(sysCompanyUserInfo.EmplId != "")
{
select * from emplTable
where emplTable.EmplId == sysCompanyUserInfo.EmplId;
if(emplTable)
{
if(emplTable.EmplId != "")
{
while select * from _ServiceDetails2
where _ServiceDetails2.EmplId == emplTable.EmplId
{
if(LastDate == any2date(0))
{
LastDate = _ServiceDetails2.DateTo;
RecId = _ServiceDetails2.RecId;
}
else
{
if(LastDate < _ServiceDetails2.DateTo)
{ LastDate = _ServiceDetails2.DateTo;
RecId = _ServiceDetails2.RecId; } } }
// if(LastDate != any2date(0))
{ select * from _ServiceDetails2 where _ServiceDetails2.RecId == RecId;
this.query().dataSourceName("_Provision").addRange(fieldnum(_Provision,OfficeName)).value(_ServiceDetails2.Office); } } } } } //super(_field, _value); }