Question

How to display the time left dynamically in UI

Hi Team,

 

I have a scenario where i have to calculate the time consistently and keep updating the same and display in the UI every second

 

For example current time is 16:00, i have gone for a break for 30 mins. in the UI the field should display the time left (4.30 - 4.00) 00h:12m:50s. Something like this , it should keep updating the time left over and display in the UI

Like 0

Like

1 comments

Hi there!

 

There is an option of how you can implement your task: 

 

1. Please go to section wizard (designer) and create there two empty string fields. Here is the article on how you can do it: 

 

https://academy.creatio.com/docs/user/no-code_customization/ui_and_busi…

 

2. Then, you need to create a replacing client module schema for the client module schema. Please find the information about it in the article by the link below:

 

https://academy.creatio.com/documents/technic-sdk/7-16/creating-custom-…

 

3. In a new replacing client schema, you are able to change the values of the fields. An example of the time feature implementation: 

 

onEntityInitialized: function() {
				this.callParent(arguments);
 
				var a = new Date();
				var b = Ext.Date.add(a, Ext.Date.MINUTE, 30);
 
				var now = Ext.Date.format(a, "H:i");
				var end = Ext.Date.format(b, "H:i");
 
				var currTime = `${now} - ${end}`;
				this.set("UsrCurrTime", currTime);

Where "UsrCurrTime" is your newly-created field name. This code will generate a "16:45 - 17.15" string. 

 

4. Thus, according to this example, you are able to implement a timer feature in a second field. You can find such a feature logic at the "Case" section > "Case Information" tab > "Terms" detail. Please debug the available functionality of a timer available on the case page and use it in your own timer.

 

Please note that even demo logic does not use a dynamic update per second/minute as this is extremely resource-intensive and not recommendable to use such an approach. 

 

Regards, 

Anastasiia

Show all comments