Crmgo Blog

Automatic setting of the date for prohibiting changes to 1C data

Automatic setting of the date for prohibiting changes to 1C data

Description of adding a method to the program that allows automatically setting the edit restriction date. This method permanently resolves the issue of controlling the edit restriction date. Probably everyone knows what an edit restriction date is, how it is set, and where. The only question is...

Automatic setting of the date for prohibiting changes to 1C data

Description of adding a method to the program that automatically sets the date for prohibiting data editing.
This method permanently solves the problem of controlling the editing prohibition date.

Probably everyone knows what the editing prohibition date is. They know how it is set and where. The only question is that someone needs to constantly monitor and set it.

Typically, for most users, the program should automatically

prevent any retroactive changes every day.

In version 8, the main problem is that the prohibition date must be set before users start working,

otherwise, after setting it, it will not take effect until users log out and log back into the program.

That is, someone must be the first to log in in the morning and immediately set the prohibition.

Imagine what that would look like?

So, here is the solution (attention, actions must be performed by a specialist)

Common Module - Full Rights - Procedure

Procedure SetDataChangeProhibitionBoundaryParameter() Export

At the beginning of the procedure, add the following code:

//Mania1C
Try
ProhibitionBoundaries = SessionParameters.DataChangeProhibitionBoundaries.Get();
PeriodBoundary = ProhibitionBoundaries["GeneralDataEditingProhibitionDate"];
Yesterday = StartOfDay(StartOfDay(CurrentDate()) - 1);
DayBeforeYesterday = StartOfDay(StartOfDay(Yesterday) - 1);
If PeriodBoundary < DayBeforeYesterday Then
Reg = InformationRegisters.DataChangeProhibitionBoundaries;
Set = Reg.CreateRecordSet();
CurrentData = Reg.Select();
While CurrentData.Next() Do
If Not IsNull(CurrentData.Organization) Then
Continue;
EndIf;
Record = Set.Add();
Record.Organization = CurrentData.Organization;
Record.User = CurrentData.User;
Record.DataChangeProhibitionBoundary = DayBeforeYesterday;
EndDo;
Set.Write();
EndIf;
Except
Message(ErrorDescription());
EndTry;

That's it. After adding this code, every day when the first user logs in, the program automatically sets the editing prohibition date for all subsequent users. (In my example, the date is automatically set for all users to the day before yesterday).

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.

Categories: 1C