My 2p about ERP Solutions, Information Worker Solutions and other software products (mainly Microsoft Dynamics AX and Microsoft SharePoint).

24 February 2008

Advanced filtering on a Dynamics AX Web Form published in a SharePoint environment

by Patrik Luca 3 comments

Tag



When you have Enterprise Portal configured within your SharePoint environment, it is possible to open your ERP data from Microsoft Dynamics AX towards every user having access to the SharePoint environment. This can be achieved by making use of Web Forms. Web Forms have no filtering possibilities compared to the regular forms in the Microsoft Dynamics AX client. End-users are only able to sort records displayed in a Web Form.
To enable advanced filtering possibilities on Web Forms, you should do a little coding in your Web Form in the Microsoft Dynamics AX environment and you should create a Web Page to display your Web Form in your SharePoint environment.
The steps to follow in your Microsoft Dynamics AX environment:


  1. Create a New Web Form

  2. Add a Datasource to the Data Sources node of the created Web Form (f.e. CustTable).

  3. Add two WebGroup controls to the Design node of the created Web Form: Filter and Grid.

  4. Add a WebGrid control to the WebGroup control Grid and add some fields of the CustTable Data Source to the WebGrid (f.e. AccountNum, Name, CustGroup and ZipCode). Set the property AllowEdit to No for each field.

  5. Set following properties to following values for the added WebGrid control

    • DataSource: CustTable

    • ShowNavigationButtons: Yes

    • VisibleRows: 25

  6. Add two WebEdit controls to the WebGroup control Filter: call them FilterName and FilterCustGroup. Set the property AutoDeclaration to Yes and the Extended Data Type to Name and CustGroupId.

  7. Add a WebButton control (Submit) to the WebGroup control Filter.

  8. Adapt the classDeclaration of the created Web Form as follows:
    public class FormWebRun extends ObjectRun
    {
    QueryBuildRange NameQBR;
    QueryBuildRange CustGroupQBR;
    Name name;
    CustGroup custGroup;
    #define.Name('WebForm_Name')
    #define.CustGroup('WebForm_CustGroup')
    }

  9. Adapt the init method of the CustTable Data Source as follows:
    public void init()
    {
    super();
    NameQBR = this.query().dataSourceNo(1).addRange(fieldNum(CustTable,Name));
    CustGroupQBR = this.query().dataSourceNo(1).addRange(fieldNum(CustTable,CustGroup));
    }

  10. Adapt the executeQuery method of the CustTable Data Source as follows:
    public void executeQuery()
    {
    ;
    if(name)
    {
    NameQBR.value(name);
    }
    else
    {
    NameQBR.value(FilterName.text());
    name = FilterName.text();
    }
    if(custGroup)
    {
    custGroupQBR.value(custGroup);
    }
    else
    {
    CustGroupQBR.value(FilterCustGroup.text());
    custGroup = FilterCustGroup.text();
    }
    super();
    }

  11. Adapt the clicked method of the Submit Web Button as follows:
    void clicked()
    {
    name = FilterName.text();
    custGroup = FilterCustGroup.text();
    CustTable_ds.executeQuery();
    super();
    }

  12. Adapt the saveViewState method as follows:
    public void saveViewState()
    {
    super();
    if(Name)
    {

    this.viewStateItem(#Name,name);
    }
    if(CustGroup)
    {
    this.viewStateItem(#CustGroup,custGroup);
    }
    }

  13. Adapt the loadViewState method as follows:
    public void loadViewState()
    {
    super();
    if(this.viewStateContains(#Name))
    {
    Name = this.viewStateItem(#Name);
    }
    if(this.viewStateContains(#CustGroup))
    {
    custGroup = this.viewStateItem(#custGroup);
    }
    }

  14. Create a Web Content->Display item for your created Web Form.


So far what is needed in your Microsoft Dynamics AX environment. Your created objects should look like this:

In our SharePoint environment, we need to display the data to our SharePoint end-users. To achieve this, follow these steps:

  1. Create a New Web Part Page.
  2. Add the Web Form Web Part to the page.
  3. Click Modify Shared Web Part.
  4. In the Dynamics Properties part, choose the menu item previously created in the WebDisplayContentItemName dropdown box.



Your SharePoint end-users are now able to use advanced filtering (wildcard filters, ...) on the Name and CustGroup field of the CustTable just like the Dynamics AX end-users can in the Microsoft Dynamics AX Client. By clicking the Submit button, the records in the CustTable Web Form are filtered, taking into account the filter values entered in the WebGroup Filter control.

Comments 3 comments
Anonymous said...

umm... how do you publish your changes? won't show up in sharepoint for some reason.

Alex P. said...

Thanks a lot, Patrik.
I found your article very useful.
It worked for me very well.

LALIT JIVNANI said...

Ya Right, about 50 % it worked for me.

Actually my requirement is that if user selects any value from Look up 1 ,automatically it should filter the second look up 2 .
And both the look ups are from two different tables .So how can i achieve this ??

Patrik Luca, Ieper, BELGIUM
Feel free to use or spread all of the content on my blog. In return, linking back to my blog would be greatly appreciated. All my posts and articles are provided "AS IS" with no warranties.

Subscribe feeds via e-mail
Subscribe in your preferred RSS reader

Subscribe feeds rss Most Read Entries

Subscribe feeds rss Recent Entries

Categories

Recommended Books


Subscribe feeds rss Recent Comments

This Blog is part of the U Comment I Follow movement in blogosphere. Means the comment field of this blog is made DOFOLLOW. Spam wont be tolerated.

Blog Archive

My Blog List

Followers

Links