Hi frnds, Today we see how to restrict the user to open form , if That form is already open by other users in AX 2012.
Here I take 2 customized Forms With customized Table.In customized table UserId field is added.
And based that user id I am Implement the code.
In child form i added Init method And Close method.
Init Method:
public void init()
{
DaxTestIn daxTestIn;
Formrun formrun;
super();
daxTestIn = element.args().record();
formrun = element.args().caller();
if (!daxTestIn.User)
{
ttsBegin;
daxTestIn.User = curUserId();
daxTestIn.doUpdate();
ttsCommit;
}
else if(daxTestIn.User != curUserId())
{
throw error(strFmt("The same AccountNum(%1) is already opened by %2", daxTestIn.AccountNum,daxTestIn.user));
}
}
Close Method:
public void close()
{
DaxTestIn daxTestIn,daxTestInLoc;
Formrun formrun;
super();
daxTestIn = element.args().record();
formrun = element.args().caller();
if (daxTestIn.User)
{
ttsBegin;
select forUpdate daxTestInLoc where daxTestInLoc.RecId==daxTestIn.RecId;
daxTestInLoc.User = ' ';
daxTestInLoc.doUpdate();
ttsCommit;
}
}
Output:
If i try open 1001 record It throw that error.
That 1001 record is is already used by other user.
Keep Daxing !!
I saw other Blog they consider SessionId and they worked on sales order.Check below link for that blog.
No comments:
Post a Comment