web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to disable editing records based on a date range on a ListPage form?

(0) ShareShare
ReportReport
Posted on by

Following are requirement for a ListPage form:

1. Created custom listPage.

2. Imported legacy data on the listPage from excel using DMF tool.

3. How do I set up or filter data on this listPage  by using a "date" range of some sort to disable old records from editing? For example, for all the records that are from Sep 1st ,1998 to June 24, 2015, I want it to be non-editable when a user clicks on it. I would like all the fields to be greyed out.

 I'm not sure how to go about this? What method to write or where to write it? ListPage form method or Detail Form method? I've build 3 custom forms.  Create Form to create new entry, Detail Form to view or edit existing entry and finally, a listPage form where all the records are shown in the grid.

Any help will be greatly appreciated!.

Running AX 2012 R3.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    syed baber Profile Picture
    11,633 on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Lhamo,

    You can filter the data on list page by writing code in list page interaction class. When you open the list page, data will be filtered based on your criteria and hence user can't edit those, because they will not be shown. For this, you need to create a new display menu item with EnumTypeParameter set to specific value and opens your list page. For example, if I want to filter the purchase order list page to show only those POs which are not yet received, I wrote the following code in  \Classes\PurchTableListPageInteraction\initializeQuery

    if (this.getListPageType() == PurchTableListPage::NotYetReceived)

       {

           rangeUserId = _query.dataSourceTable(tableNum(purchTable)).addRange(fieldNum(purchTable, CreatedBy));

           rangeUserId.value(queryValue(curUserId()));

           rangeUserId = _query.dataSourceTable(tableNum(purchTable)).addRange(fieldNum(purchTable, PurchStatus));

           rangeUserId.value(SysQuery::valueNot(PurchStatus::Received));

    }

    I have created a new element NotYetReceived in PurchTableListPage enum. You can use the similar logic to filter the records on your list page. Just write the code your list page interaction class. For enabling/disabling any controls on your list page, you need to check SetButton*** methods on list page interaction class. For example, take a look at PurchTableListPageInteraction class.

    Please let me know if you have further queries.

    thanks,

    Baber.

  • Suggested answer
    Faisal Fareed Profile Picture
    10,796 User Group Leader on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Lhamo,

    Your list page must be using a listPageInteraction class as you cannot write code on list pages. Have a look on /Forms/CustTableListPage right click on it you will in properties it is binded with custTableListPageINteraction class. Now open this class, you will see SelectionChanged() there you will find enableInvoiceAndCollectionGroupButton() method.

    Now, all you need to override this selectionChange() method in your interaction class and write similar code as in enable*** methods to cater your requirement.

  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Lhamo

    It sounds like you still want to be able to see the records in your list page, so adding ranges or filters to the list page is simply going to hide the records rather than actually disable editing.

    I think your solution, as with most standard forms, is to add your business rules into the actual details form and leave the list page as is. On this form in the active method of your datasource simple change the editable status of the datasource. You may for extra security add some code to the update or validateWrite method of your actual table to prevent update on a more global level too.

    Note even on purchase order form you can click the "edit" button on the list page to display the details even if the details form physically doesn't allow you to edit.

  • Community Member Profile Picture
    on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hello Jonathan,

    You got it right in terms of what I'm trying to achieve. How or what method do I write on detail form? I still have to put that date range in place.

    Thanks for the help!

  • Suggested answer
    syed baber Profile Picture
    11,633 on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Lhamo,

    You can disable editing on details form for individual field or for whole datasoure. The datasource object has an allowEdit method which you can set to true or false to enable/disable editing. Please tell me on which date ranges you want to enable or disable editing and then I will let you know where to write the code.

    Thanks,

    Baber.

  • Community Member Profile Picture
    on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Baber,

    Thanks so much for helping out. Let me explain it more clearly.

    1. I've imported existing data using DMF tool(excel file). Thus, all the data are showing on this listPage form.

    2.  My goal is to make imported records non-editable but new entered records can still be editable on detail page. When I double click on one of the record, it will open up the Detail Form which contains specific record. I want records to be filtered through date range.

    3. For all the imported records from data 05/02/1998 to 06/25/2015, when it's opened  by double clicking on the grid or open using edit menu button, I would like all these records to be non-editable, only for viewing purpose.

    4. We are bringing legacy data to data storage purpose only and to look up information when needed.

    5. I would share scree shots but im not able to due to large image size.

    Thanks so much for your help!

  • Suggested answer
    syed baber Profile Picture
    11,633 on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Lhamo,

    You can disable editing on the whole datasource or on individual field based on the date range. You can write the code in detail's form init method after super() method call. The code is shown below:

    if (FromDate >= mkDate(05,02,1998) && ToDate <= mkDate(06,25,2015))

    {

       // To disable editing on the datasource

       YourDateSourceName_ds.allowEdit(false);

       // To disable editing on individual fields of the datasource

       YourDataSourceName_ds.object(fieldNum(YourDataSourceTable, FieldName)).allowEdit(false);

    }

    Please use the above code and let me know if you need further help.

    Thanks,

    Baber.

  • Community Member Profile Picture
    on at
    RE: How to disable editing records based on a date range on a ListPage form?

    hi babar,

    Can you please guide me how to block Personalize option for a List Page.

    As far as I understood we need to write the code in the List Page Interaction Class.

    Please share if you have any idea.

    I am trying to disable personalize option in PurchTableListPage.

    Regards
    Wamik

  • syed baber Profile Picture
    11,633 on at
    RE: How to disable editing records based on a date range on a ListPage form?

    Hi Wamik,

    Why do you want to block personalize option on list page ? Any specific requirement you want to achieve ? Please elaborate. I have never done this though, so need to check if it is possible or not.

    Thanks,

    Baber.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans