[DataSource]
class InventLocation
{
void executeQuery()
{
QueryBuildDataSource qbdsInventLocation;
DictRelation dr;
Counter i;
FormDataSource callerFormDatasource;
DictType dt;
ExtendedTypeId extendedTypeId;
FieldId inventSiteFieldId;
Common cursor;
//if queryRun object is created use query from it
//this allows to modify query that is used in filtered lookups
if (this.queryRun())
{
qbdsInventLocation = this.queryRun().query().dataSourceTable(tableNum(InventLocation));
}
else
{
qbdsInventLocation = this.query().dataSourceTable(tableNum(InventLocation));
}
inventSiteFieldId = inventDimFormSetup.callerInventSiteFieldId();
qbdsInventLocation.clearDynalinks();
if (inventSiteFieldId)
{
cursor = inventDimFormSetup.callerInventSiteIdCursor();
if (cursor.TableId != tableNum(Common) && cursor.(inventSiteFieldId))
{
qbdsInventLocation.addDynalink(
fieldNum(InventLocation,InventSiteId),
cursor,
inventSiteFieldId);
}
}
FormStringControl ctrl = element.selectTarget() as FormStringControl;
if (ctrl)
{
extendedTypeId = ctrl.extendedDataType();
if (extendedTypeId)
{
dt = new DictType(extendedTypeId);
dr = dt.relationObject();
}
else
{
callerFormDatasource = inventDimFormSetup.callerFormDatasource();
if (callerFormDatasource)
{
dr = new DictRelation(callerFormDatasource.table());
dr.loadFieldRelation(ctrl.dataField());
}
}
}
if (dr)
{
for (i=1;i<=dr.lines();i++)
{
switch (dr.lineType(i))
{
case TableRelation::ExternFixed:
qbdsInventLocation.addRange(dr.lineExternTableValue(i)).value(queryValue(dr.lineTableValue(i)));
break;
}
}
}
super();
}
[ExtensionOf(formDatasourceStr(InventLocationIdLookup, InventLocation))]
final class DTInventLocationIdLookup_InventLocationDS_Extension
{
public void executeQuery()
{
QueryBuildDataSource qdbs;
next executeQuery();
FormRun formrun = this.formRun().args().caller();
FormDataSource SalesLine_ds,InventLocation_ds,SalestableInventDim_ds;
UserId userId = curUserId();
DTUserInfo dtUserInfo;
InventLocation inventLocation;
DTSalesTransactionAccess salesTranAccess,salesTranAccess1;
Common common;
InventDim inventDim;
Container LocationId;
FieldId inventSiteFieldId;
common = formrun.dataSource(formDataSourceStr(SalesTable, SalesLine)).cursor();
inventDim = formrun.dataSource(formDataSourceStr(SalesTable, InventDim)).cursor();
select firstonly inventLocation
where inventLocation.InventLocationId == inventDim.InventLocationId;
;
select firstonly salesTranAccess
where salesTranAccess.UserId == userId
&& salesTranAccess.Stock == NoYes::Yes
&& salesTranAccess.inventLocationId == inventDim.InventLocationId
&& salesTranAccess.UserId == common.CreatedBy;
if( salesTranAccess.RecId != 0 )
{
while select * from salesTranAccess
where salesTranAccess.UserId == userId
&& salesTranAccess.Stock == NoYes::Yes
{
LocationId += salesTranAccess.inventLocationId;
}
str invLocationId = con2Str(LocationId,",");
inventSiteFieldId = inventDimFormSetup.callerInventSiteFieldId();
qdbs = this.query().dataSourceTable(Tablenum(InventLocation));
qdbs.addRange(fieldnum(InventLocation, InventLocationId)).value(invLocationId);
}
}
}
[ExtensionOf(formStr(InventLocationIdLookup))]
final class InventLocationIdLookup_Extension
{
void init()
{
next init();
InventLocation_ds.executeQuery();
}
}
[ExtensionOf(formDatasourceStr(InventLocationIdLookup, InventLocation))]
final class DTInventLocationIdLookup_InventLocationDS_Extension
{
public void executeQuery()
{
QueryBuildDataSource qdbs;
next executeQuery();
FormRun formrun = this.formRun().args().caller();
FormDataSource SalesLine_ds,InventLocation_ds,SalestableInventDim_ds;
UserId userId = curUserId();
DTUserInfo dtUserInfo;
InventLocation inventLocation;
DTSalesTransactionAccess salesTranAccess,salesTranAccess1;
Common common;
InventDim inventDim;
Container LocationId;
common = formrun.dataSource(formDataSourceStr(SalesTable, SalesLine)).cursor();
inventDim = formrun.dataSource(formDataSourceStr(SalesTable, InventDim)).cursor();
select firstonly inventLocation
where inventLocation.InventLocationId == inventDim.InventLocationId;
;
select firstonly salesTranAccess
where salesTranAccess.UserId == userId
&& salesTranAccess.Stock == NoYes::Yes
&& salesTranAccess.inventLocationId == inventDim.InventLocationId
&& salesTranAccess.UserId == common.CreatedBy;
if( salesTranAccess.RecId != 0 )
{
while select * from salesTranAccess
where salesTranAccess.UserId == userId
&& salesTranAccess.Stock == NoYes::Yes
{
LocationId += salesTranAccess.inventLocationId;
}
str invLocationId = con2Str(LocationId,",");
qdbs = this.query().dataSourceTable(Tablenum(InventLocation));
// your code
qdbs.addRange(fieldnum(InventLocation, InventLocationId)).value(invLocationId);
}
}
}
Martin Dráb
445
Most Valuable Professional
Abhilash Warrier
310
Saalim Ansari
261