Announcements
HI All
The following code when executed is opening customer form for account number specified i.e. 0001
static void Job1(Args _args) { MenuFunction menuFunction; CustTable bufferRecord; _args = new Args(); bufferRecord = CustTable::find('0001'); menuFunction = new MenuFunction(menuitemDisplayStr(CustTable), MenuItemType::Display); _args.record(bufferRecord); menuFunction.run(); }
but when the same code is executed for the custom table is opening first record in table instead of the record with recid 5637161829.
static void Job1(Args _args) { MenuFunction menuFunction; MyCustomTable bufferRecord; _args = new Args(); bufferRecord = MyCustomTable::findbyRecId(5637161829); menuFunction = new MenuFunction(menuitemDisplayStr(MyCustomTable), MenuItemType::Display); _args.record(bufferRecord); menuFunction.run(); }
Hi Martin
Looking at Query tab revealed that there were two tables out of which one does not have any relation at all with MyCustomTable and there was no direct relation for other table on form. The relation for the later table was set on modified method of field using QueryBuildDataSource.
As this form was developed by other developer and I do not want to mess up with his code, I applied the workaround mentioned in this blog and it is working fine.
Thanks
Then I would do the two things I already mentioned.
Look at the query - you can see it in the Personalization form. What you'll do next depends on how what you find there.
But you can also try another thing - if the table doesn't have a relation to itself (typically through a data type used for it's primary column), try adding it. To be honest, I don't remember if this is needed, but you can easily test this theory.
I added following infolog in form's init method and it is showing correct recid.
info(strFmt("%1", element.args().record().RecId));
Do you get the right record in form's init()?
How does the resulting form query look like?
@Nikolas, the record is passed in line # 12 in both jobs. Moreover, record with recid exists in MyCustomTable.
@Martin, MyCustomTable is first data source on the form. I do not see any code that might be preventing the standard behavior. Although, there are other tables on the form but when I am opening that record from list page it is working fine.
Is MyCustomTable the first data source of the form? What about relations?
Doesn't the form contain code that breaks the standard behaviour?
By the way, please use Insert > Insert Code (in the rich-formatting view) to paste source code. It preserves indentation, which makes code much easier to read.
Your both jobs have the same bug: you don't pass the args when you call menuFunction.run().
Please fix that and try again. The first job just happens to "work" since you perhaps selected the first CustTable record ("0001"), and the form shows the first record even without any args being passed.
Second, did you debug your job to make sure that a bufferRecord was actually found with that rec id?
André Arnaud de Cal...
294,206
Super User 2025 Season 1
Martin Dráb
232,968
Most Valuable Professional
nmaenpaa
101,158
Moderator