Skip to main content

Notifications

Small and medium business | Business Central, N...
Unanswered

Change the value of Option Field automatically after few days

(0) ShareShare
ReportReport
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 

  • YUN ZHU Profile Picture
    YUN ZHU 74,036 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,959 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans