Skip to main content

Notifications

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 203
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.
  • Nil@@m Profile Picture
    Nil@@m 203 on at
    How to get/find 10 min from time in business central.
    Thank you so much ,Yes i am already verify the answer.
  • Verified answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,744 on at
    How to get/find 10 min from time in business central.

    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.

  • Verified answer
    Nil@@m Profile Picture
    Nil@@m 203 on at
    How to get/find 10 min from time in business central.
    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.
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,036 Super User 2024 Season 2 on at
    How to get/find 10 min from time in business central.
    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
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,744 on at
    How to get/find 10 min from time in business central.
    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
  • Nil@@m Profile Picture
    Nil@@m 203 on at
    How to get/find 10 min from time in business central.
    Hi @Yi Yong,
     
    Do you have any record with an empty 'Planned Date' field? ->Yes
  • Suggested answer
    Yi Yong Profile Picture
    Yi Yong 1,450 Super User 2024 Season 2 on at
    How to get/find 10 min from time in business central.
    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.
  • Nil@@m Profile Picture
    Nil@@m 203 on at
    How to get/find 10 min from time in business central.
    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
  • gdrenteria Profile Picture
    gdrenteria 12,290 Most Valuable Professional on at
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 4,744 on at
    How to get/find 10 min from time in business central.
    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/

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