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

Announcements

No record found.

News and Announcements icon
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 333
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.
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    23,159 Super User 2026 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
    27,623 Super User 2026 Season 2 on at
  • Test user Profile Picture
    333 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,805 Super User 2026 Season 1 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
    333 on at
    Hi @Yi Yong,
     
    Do you have any record with an empty 'Planned Date' field? ->Yes
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    23,159 Super User 2026 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
    103,712 Super User 2026 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
    333 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
    23,159 Super User 2026 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
    333 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 740 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 570 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 291 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans