We are using different menu item buttons for different types of purchase orders which we created. all menu items will land to purchaseorderlistpage. we applied the range on list page according to purchase order type (menuitembutton). but when data is empty in a company and we click new purchase order button, it won't recognize the purchase type sent by menu item because range return zero records.
so what could be the possible answer to this solution ?
So when you click New > Purchase order form the ActionPane you want the Purchase order type to be defaulted to that of the filter on the list page set by which ever menu item was used to call it?
Christopher Paul Ironmonger, MSc (Dist.), BSc (Hons.)Microsoft Dynamics AX Developer
This post is my own opinion and does not necessarily reflect the opinion(s) or view(s) of my current employer(s), nor Microsoft and it's employees.
ok so your code needs to handle this, currently your code only applies a filter to the list page however when you click the button to create a new purchase order the code behind this functionality knows nothing of your query ranges on your list page.
Looking quickly at it, the menu item the button uses is PurchTableForNew_Action you may be able to utilise the parameter property to pass on which type you want to default the order type to.
Then with this value is scope you can use it to set the forms field value using the initValue method of the data source.