How to call Form with filtered records using code in AX 2012

You could have found posts on “How to call Form using code”, but, here, my post relates to calling a Form with filtered records.

Here is the Sample Code snippet………………..

static void runFormWithFilteredRecords()
{

Args args = new Args(formStr(_Employee));
FormRun formRun;
FormDataSource formDataSource = new FormDataSource();
;

formRun = ClassFactory.formRunClass(args);
formRun.init();
formDataSource = formRun.dataSource();
formRun.run();
formDataSource.filter(fieldNum(EmployTbl,FirstName), “vinoth”);
formRun.detach();

}

I have written small piece of code to make you understand easily. So, firstly, I am instantiated Args Class with parameter as FormName, declared FormRun object, then Instantiated FormDataSource Class.

Now, Assigned formRun object to Global Class ClassFactory which has a method named  formRunClass with parameter as args. I called init() method which initializes the process, assigned formDataSource with  formRun.dataSource() which returns form datasource table as a object.

Form gets called but it needs to be filtered. So, formDataSource which has Datasource Table object will filter the record with specified parameters and fetched the result.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: