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 .
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)); } } }
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.
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.
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)); }
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.
Thanks Martin, I've updated the code.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
André Arnaud de Cal... 734 Super User 2025 Season 2
CA Neeraj Kumar 636
Martin Dráb 553 Most Valuable Professional