Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Automatic Calculation of Time Remaining How do I make a new column

Forum

Search UsersRules
Automatic Calculation of Time Remaining How do I make a new column
#1
Just came
Points:: 0
Joined:: Sep 29, 2016

Beforewrite did with the method, but not the way I want

How do I write to autorefresh method ? Or How do I make ?

Profile
#2
Just came
Points:: 0
Joined:: Jun 10, 2016

Can you use ConditionalAppearance property of form?

Profile
#3
Active user
Points:: 0
Joined:: Apr 18, 2012

Hi Mehmet!

It's hard to say what works wrong in your code.
I advise to use function Int() instead Number(Format()).
Also you can use debugger for finding trouble.

I wrote similar code, it works

Code
Minutes = Int((ThisObject.AttributeDate - CurrentDate()) / 60);
If Minutes < 0 Then
   ThisObject.AttributeString = "OK";
EndIf;

Profile
#4
Just came
Points:: 0
Joined:: Sep 29, 2016

Hi!
Alexei Khatin,

I was working Codes but,I want continuous calculation of the remaining time

PresentationGetProcessing() method not set field KalanSüre
how do make it

Profile
#5
Active user
Points:: 0
Joined:: Apr 18, 2012

Hi, Mehmet.

I suggest the most easiest solution, that I could find.

1. Create information register "RemainingTime"

2. Check flag "Custom Query" in the list form of the document

3. Open "list setup" (hyperlink under checkbox) and modify query text

4. Put new column "Time" on the form

5. Create scheduled task for filling register "RemainingTime"
Check flags "Use" and "Predefined" for scheduled task
Setup schedule: Perform: every  day; every 60 second
Check flags "Server" and "Plivileged" for common module "ScheduledJobsServer"

Code of the task:

Code
Procedure UpdateRemainingTime() Export
   Now = CurrentDate();
   Query = New Query;
   Query.Text = 
   "SELECT
   |   Document3.Ref,
   |   Document3.AttributeDate
   |FROM
   |   Document.Document3 AS Document3
   |WHERE
   |   Document3.AttributeDate > &CurrentDate";
   
   Query.SetParameter("CurrentDate", Now);
   
   QueryResult = Query.Execute().Select();
   
   RecordSet = InformationRegisters.RemainingTime.CreateRecordSet();
   While QueryResult.Next() Do
      Record = RecordSet.Add();
      Record.Document = QueryResult.Ref;
      Record.Time = GetRemainingTimeText(QueryResult.AttributeDate, Now)
   EndDo;
   RecordSet.Write();
EndProcedure

Function GetRemainingTimeText(AttributeDate, Now) Export
   Minutes = Int((AttributeDate - Now) / 60);
   Hours = Int(Minutes / 60);
   Days = Int(Hours / 24);
   
   Minutes = Minutes - 60 * Hours;
   Hours = Hours - 24 * Days;
   
   Result = "";
   If Days > 0 Then
      Result = Result + " " + Days + " days"
   EndIf;
   If Hours > 0 Then
      Result = Result + " " + Hours + " hours"
   EndIf;
   If Minutes > 0 Then
      Result = Result + " " + Minutes + " minutes"
   EndIf;
   Result = Result + " left";
   
   Return Result;
EndFunction


Note, in file mode tasks start two minutes after session start.

6. Enjoy result

7. Also you can add this code in the document's module for instant upd ate when you save document
Code
Procedure OnWrite(Cancel)
   RecordSet = InformationRegisters.RemainingTime.CreateRecordSet();
   RecordSet.Filter.Document.Set(Ref);
   Now = CurrentDate();
   If AttributeDate > Now Then
      Record = RecordSet.Add();
      Record.Document = Ref;
      Record.Time = ScheduledJobsServer.GetRemainingTimeText(AttributeDate, Now)
   EndIf;
   RecordSe t.Write();
EndProcedure

Profile
#6
Active user
Points:: 0
Joined:: Apr 18, 2012

In version 8.3.10 will be new functionality and it would be much easier to solve this problem

Here is a link, if you can understand something in Russian.
<the links should open pages in English>

Profile
#7
Just came
Points:: 0
Joined:: Sep 29, 2016

Alexei Khatin,

thank you, I worked apply the method

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.