Record Level Security in ax 2009
Class detraction
Querybuildrange
qbruser;
**************
public void executeQuery()
{
qbruser.value(queryvalue(curuserid()));
super();
}
***********************************
public void init()
{
super();
qbruser =
this.query().dataSourceName('SalesTable').addRange(fieldnum(SalesTable,createdby));
}
**********************************************
other part apply method in run () At last
other part apply method in run () At last
if(Range.Table_Id == _salestable.TableId )
{
Range.RangeValue = s;
}
saveCueBtn.enabled(this.saveCueEnabled());
This is a modification to SysQueryRun.new to use RLS on depended tables. (by OIP from AxForum)
public void new(anytype _p1) { // custom RLS, OIP, 05.09.06 --> int i,j,k; QueryBuildRange r; QueryBuilddatasource ds; QueryBuilddatasource childDS; QueryBuilddatasource intDS; QueryBuilddatasource restrictDS; Query q; SysRecordLevelSecurity RLSTable; Query restriction; userGroupId groupId; userGroupList groupList; // custom RLS, OIP, 05.09.06 <-- if (_p1) { super (_p1); if (this.args() && !this.args().caller() && typeOf(_p1) == Types::Class && !SysdictClass::isEqualOrSuperClass(classidget(_p1), classNum(Query))) { this.args().caller(_p1); } // custom RLS, OIP, 05.09.06 --> q = this.query(); for(i=1; i<= q.dataSourceCount(); i++) { ds = q.dataSourceNo(i); while select RLSTable where RLSTable.tabId == ds.table() && RLSTable.companyId == curext() join groupList where groupList.groupId == RLSTable.groupId && groupList.userId == curUserId() { if(RLSTable.restriction != conNull() && sysQuery::isPackedOk(RLSTable.restriction)) { restriction = new QueryRun(RLSTable.restriction).query(); if(restriction.dataSourceCount()>1) { for(j=2;j<= restriction.dataSourceCount();j++) { restrictDS = restriction.dataSourceNo(j); intDS = restrictDS.parentDataSource(); if (!SysQuery::tableOccurrence(q, restrictDS.table(), q.dataSourceCount())) { childDS = q.dataSourceTable(intDS.table()).addDataSource(restrictDS.table()); childDS.relations(true); childDS.joinMode(JoinMode::ExistsJoin); childDS.fetchMode(QueryFetchMode::One2One); } else { childDS = q.dataSourceTable(restrictDS.table()); } for(k=1;k<=restrictDS.rangeCount();k++) { r = childDs.addRange(restrictDS.range(k).field()); r.value(restrictDS.range(k).value()); r.status(RangeStatus::Hidden); } } } } } } this.origQueryPack(q.pack(false)); } // custom RLS, OIP, 05.09.06 <-- loadLastUsedQuery = true; saveQueryPrUser = true; allowSave = true; allowAddRange = QueryAllowAdd::AllFields; allowAddSorting = QueryAllowAdd::AllFields; showSorting = true; }
No comments:
Post a Comment