Announcements
Hello..
form has two data sources, I created a class Extended the form data source init method using the COC, and added some ranges ,also I need to access the other data source in the form ,to know the active record
Thanks all .
Thanks Martin, I've updated the code.
I've seen this pattern in vendor's code and I don't understand it's purpose:
FormDataObject formDataObject = any2Object(this) as FormDataObject;
Why don't you simply refer to 'this'?
any2Object() isn't useful, because 'this' already is an object instance.
'as FormDataObject' doesn't look useful either. No casting isn't needed, AFAIK, and we also don't need to check whether the current object has the right type.
Hi Ahmed
I see this is an old post, but just in case it helps someone else ...
I had a similar requirement where I had to access datasource 1 (let's call it that), whilst extending the 'modified' field on datasource 2. This is the code I used to achieve this:
public void modified() { FormDataSource dataSource2 = this.datasource(); next modified(); QueryRun queryRun = dataSource2.queryRun(); Table1 table1 = queryRun.get(tableNum(Table1)); }
Hi Ahmed Osama,
The code "FormDataSource smmBusRelTable_ds = this.formRun().dataSource(formDataSourceStr(PurchEditLines, PurchParmUpdate));" doesn't make any sense here.
You could try to use OnInitialized eventhandler of your formdatasource.
You're in init() method - no data has been loaded from database at this point. Loading of data happens later, after the data source is initalized and executeQuery() gets called. That's why the table buffer is always at this point.
Same issue , can't access to the other DS
[ExtensionOf(formdatasourcestr(PurchEditLines, InventDim))] final class BT_PurchEditLines_Form_Extension { public void init() { QueryBuildDataSource qbds,qbdsUser,qbdsLocation,qbdsInventDim; PA_WarehousesUsers PA_WarehousesUsers; InventLocation inventlocation; PurchParmUpdate PurchUpdate; PurchUpdate qty; FormDataSource smmBusRelTable_ds = this.formRun().dataSource(formDataSourceStr(PurchEditLines, PurchParmUpdate)); PurchUpdate = smmBusRelTable_ds.cursor(); next init(); str user = curUserId(); select PA_WarehousesUsers where PA_WarehousesUsers.UserId == user; if(PA_WarehousesUsers )//&& purchParmUpdate.SpecQty == PurchUpdate::PackingSlip) { qbds = this.query().dataSourceTable(tableNum(InventDim)); qbdsUser = qbds.addDataSource(tableNum(PA_WarehousesUsers)); qbdsUser.addLink(fieldNum(PA_WarehousesUsers, InventLocationId), fieldNum(InventDim, InventLocationId)); qbdsUser.addRange(fieldnum(PA_WarehousesUsers, UserId)).value(queryValue(user)); } } }
André Arnaud de Cal...
294,069
Super User 2025 Season 1
Martin Dráb
232,858
Most Valuable Professional
nmaenpaa
101,158
Moderator