Hi there,
I am trying to add range\s in the init method of a form, in order to force that form to open for the current user of the AX session. I must find a way to bind the EmplTable.emplId to SysUserInfo.Id (in order to find the current user opening the session).
Practically, when my form opens, it opens on the first record from the EmplTable, not on the current user for the session (currentUserId) .
I also looked at this community post:
https://community.dynamics.com/ax/b/makecreatereiterate/archive/2015/01/06/how-to-add-a-range-or-data-source-to-a-form-data-source
The problem is that my EmplTable and SysUserInfo do not have common fields.
I managed to add the range for Empltable.EmplId, however, I don't fully understand how I can make the form to open on the currentUserId.
My code is written in the init() method of the form data-source(EmplTable) and looks like this:
public void init()
{
EmplId emplId;
QueryBuildDataSource dsEmplTable;
Query query;
;
emplId= Empltable.EmplId;
query = new query();
// info(strfmt("%1",emplId));
super();
dsEmplTable =query.adddataSource(tableNum(EmplTable));
//add the range:
dsEmplTable.addRange(fieldnum(EmplTable, EmplId));
}
I hope I clearly explained my problem :)
Please help. Thank you!
edit: my form updates info in some EmplTable fields, and that's why it should open on the current EmplId.