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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to get/find 10 min from time in business central.

(1) ShareShare
ReportReport
Posted on by 289
Hi Guys,
 I want to give an styleexp on field which is based on condition:
Condition : I have one page.Call Distribution.On that page there is one field.i.e. Planned time
for example : planned time field has value is : 4:00:00 PM.
So before 10 minutes the planned time, for this field gets green color . means
If it is 10 min less than 4 o'clock,the colour of that field should be greeen
. and once passed the time it should turn red colour.
Is any way to do this.
I have the same question (0)
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,448 Super User 2025 Season 2 on at
    Yes, you can achieve this in Microsoft Dynamics 365 Business Central by using a combination of AL code for conditional styling and page extension customization.

    For some hint: https://yzhums.com/1599/
  • Gerardo Rentería García Profile Picture
    25,234 Most Valuable Professional on at
  • Test user Profile Picture
    289 on at
    I know the knowlege behind the styleexp. i just want to know that 10 min condiction part.
    like as per Yunzhu blogs,i have wriiten the same code but i am getting this type of error .my page is not opening
  • Suggested answer
    Yi Yong Profile Picture
    2,563 Super User 2025 Season 2 on at
    Hello,
     
    Do you have any record with an empty 'Planned Date' field?
     
    You might want to add a condition to make sure the calculation only takes place when both 'Planned Date' and 'Planned Time' are not blank.
  • Test user Profile Picture
    289 on at
    Hi @Yi Yong,
     
    Do you have any record with an empty 'Planned Date' field? ->Yes
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,448 Super User 2025 Season 2 on at
    Hi, Code


    Output: The system turns Planned time field green 10 minutes before time.

    After it will turns into red.


    Hope this will solve your issue.

    Regards,
    Khushbu Rajvi
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    Hi, In the latest version, you can use the following method directly.
    Business Central 2024 wave 2 (BC25): New Date/Time/DateTime methods
     
    Thanks.
    ZHU
  • Verified answer
    Test user Profile Picture
    289 on at
    Yes,this code its working Now. just for my clearness,can you please describe the code.so it will helpful for me.
    Thank you for your guidance.
     
  • Verified answer
    Khushbu Rajvi. Profile Picture
    20,448 Super User 2025 Season 2 on at

    The code defines a field for "Planned Time" with a style controlled dynamically by the StyleExprTxt variable. The OnAfterGetRecord trigger updates StyleExprTxt by calling the GetStyleBasedOnTime procedure from the TimeStyle codeunit. This procedure sets the field's style based on the current time and the planned time value:
    It returns 'favorable' if the current time is within 10 minutes before the planned time.
    It returns 'Unfavorable' if the current time is past the planned time.
    It returns an empty string as a default if neither condition is met.

    Don't forget to like and close it by verifying if answer is satisfied.

  • Test user Profile Picture
    289 on at
    Thank you so much ,Yes i am already verify the answer.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans