Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Unanswered

Change the value of Option Field automatically after few days

Posted on by 50

There is one Requirement from client that, one Option filed having value like unsolved and solved, by default it is Unsolved but after click on action button then after three days the value should automatically change to Solved 

Categories:
  • YUN ZHU Profile Picture
    YUN ZHU 70,116 Super User 2024 Season 2 on at
    RE: Change the value of Option Field automatically after few days

    Hi, Very interesting question. Generally, you can set up the an Job Queue, for example, check the status every night, and modify the status if it is more than three days.

    pastedimage1663721490242v1.png

    Hope this helps.

    Thanks.

    ZHU

  • Amit Baru Profile Picture
    Amit Baru 3,025 on at
    RE: Change the value of Option Field automatically after few days

    Hi,

    Pls check with technical person in AL, option or enum values changed in the AL code.

    Regards

    Amit Sharma

    www.erpconsultors.com

  • RE: Change the value of Option Field automatically after few days

    Hi,

    I suggest you should create a separate table to have the Button Click Log Entries.

    Therefore, you can see how it has changed from unsolved to solved with Date and Time also you can capture the User who click on the action button with the Document No and Value Changed Boolean.

    In trigger OnAction() of the Action Button you are pressing, you have to assign the values and insert a record to the Log Entries Table.

    Afterwards you have to create a codeunit to check Date & Time field whether it has passed 3 days by comparing WorkDate() and DateTime field in Log Entry Table. If so, modify the particular document via the Document No. field in the Log Entry Table and change the Option field to Solved.

    Moreover, you must modify the Value Changed Boolean field to True in Log Entry Table. Therefore, you could set the codeunit only run if the Value Changed Boolean is False.

    Finally create a job queue entry to the above created codeunit and set it to run daily.

    This solution not only a good way to change the option field after 3 days of clicking the button, but also to keep a track on what option was there on what date & time, when did the option changed with date & time with the User who clicked the button initially for the reporting and auditing purposes

    If the solution is not understandable to you, please do reply as I will give you with an example.

  • Ben Baxter Profile Picture
    Ben Baxter 4,591 Super User 2024 Season 2 on at
    RE: Change the value of Option Field automatically after few days

    Potential duplicate, but providing the same information in case someone finds this thread:

    I would add a third option to your string: "Pending"

    Have a second field, that is a date field, hidden and non-editable.  When the action button is triggered, it switches your option field to Pending and adds today's date to your date field.  Have a Job Queue batch that runs once a day and looks for records Pending with a date older than three days, and switches them to Solved.

    If the User takes action on the record, it should set status back to Unsolved and clear the date field, then the system won't mark it as Solved.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans