Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

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

Posted on by 161
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.
Categories:
  • Nil@@m Profile Picture
    Nil@@m 161 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. 1,718 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 161 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 69,864 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. 1,718 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 161 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 802 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 161 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 9,579 Most Valuable Professional on at
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 1,718 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

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,552 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,552 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans