Start here

Advertisements

Hold/ Focus Form Until Close

Modal forms in Dynamics AX

I recently i had a scenario, where i had to run a Survey in Dynamics AX which will appear when user open his Dynamics client. Which i Achieved by calling my form on Info class.

The problem arrived when User minimizing the Survey and keep using Dynamics , So i have to Implement a check to hold the Dynamics Until he fill and Submit the Survey.

To Achieve this I simply added this command in Run method of my Form.

element.wait(true);

 

public void run()
{
    super();
    element.wait(true);
    // Execution will resume at this point, only after the user has closed the form.
}

 

This done the trick, Happy Daxing.

 

Advertisements

Restrict non-admin users to open multiple sessions in AX 2012

Copy Paste the Following Code in startupPost method of info class in AOT

void startupPost()
{

xSession session;
SysClientSessions SysClientSessions;
UserId currentUserId;
int counter;

 

currentUserId = curUserId();

if (!isSystemAdministrator())// Allow Admin User to login multiple time
{
while select SysClientSessions
where SysClientSessions.userId == currentUserId
&& SysClientSessions.clientType == 0
{
session = new xSession(SysClientSessions.SessionId, true);
if (session && session.userId())
{
counter++;
}
}

if (counter >= 2)
{
Box::stop(“Already Logged-in : The same user id can’t log in twice.”);
infolog.shutDown(true);
}
}

}

Hide Export file format : SSRS Report Viewer using X++

Sample Code to hide the Export option from SSRS report viewer using x++

IMG1

 

STEP 1: First We need to add the reference “Microsoft.ReportViewer.WinForms” in AOT

reference

STEP 2:  Add the below code into the Form “SRSReportViewer’

FormCode.PNG

 

public void hideExportButton()public void hideExportButton()

{

System.Windows.Controls.UIElementCollection children;    Microsoft.Reporting.WinForms.ReportViewer reportViewer;

children = _axreportViewer_control.get_Children();    reportViewer = children.get_Item(0);
reportViewer.set_ShowExportButton(false);

}

 

STEP 3: Now call this code into the run method of this form with the desired report name

Code.png

 

Result :

 

Result.PNG

 

 

 

 

 

 

Form event execution sequence in Dynamics AX

This Blog will guide the sequence of event triggering while working on Form’s and Table in Dynamics AX.

Form Events

Table EventsTable Evnts2

 

Images from the Original blog of Afnan Zarif.

Emploee Lookup – Legal entity specific – Active Emploee

Sample Code to generate Employee Lookup . Which contains Active employee, Legal entity specific and here i have an extra filter to exclude workers starting from 00.

You can also use the same code to get the Terminated employee just by Slight change in the query .

public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;

QueryBuildDataSource queryBuildDataSource1;
RecId _LegalEntity;
;

//Create an instance of SysTableLookup with the form control passed in
sysTableLookup = SysTableLookup::newParameters(tablenum(HcmWorker), this);

//Add the fields to be shown in the lookup form
sysTableLookup.addLookupfield(fieldnum(HcmWorker, PersonnelNumber), false);
sysTableLookup.addLookupMethod(‘Name’);

//create the query datasource
queryBuildDataSource = query.addDataSource(tablenum(HcmWorker));
queryBuildDataSource.addRange(fieldNum(HcmWorker, PersonnelNumber))
.value(SysQuery::valueLikeAfter(‘!00’));

queryBuildDataSource1 = queryBuildDataSource.addDataSource(tableNum(HcmEmployment));
queryBuildDataSource1.joinMode(JoinMode::ExistsJoin);
queryBuildDataSource1.relations(true);
queryBuildDataSource1.addRange(fieldNum(HcmEmployment, LegalEntity))
.value(SysQuery::value(CompanyInfo::findDataArea(SelectableDataArea.valueStr()).recId));

//add the query to the lookup form
sysTableLookup.parmQuery(query);

// Perform lookup
sysTableLookup.performFormLookup();

}

Syed Wajahat Ali

April 2018
M T W T F S S
« Mar    
 1
2345678
9101112131415
16171819202122
23242526272829
30