I started using Live Fields by appfire , if you have jmwe you can use it witch I have.
I am trying to perevent people to log work after the 5th a-day of the month for the dates before.
const today = new Date();
const currentMonth = today.getMonth() + 1; // Mevcut ay (1 = Ocak, 12 = Aralık)
const currentDay = today.getDate();
if (currentDay > 5) {
// Önceki ayın son günü
const lastAllowedDate = new Date(today.getFullYear(), currentMonth - 1, 0); // Geçerli aydan bir önceki ayın son günü
// Time Spent alanındaki değeri kontrol et
LiveFields.onFieldChange('timespent', function(field, value) {
const logDate = new Date(value); // Kullanıcının girdiği zamanı al
// Eğer log tarihi önceki ay veya daha eskiyse uyarı ver ve değeri temizle
if (logDate <= lastAllowedDate) {
logger.warn('Geçerli ayın 5\'inden sonra önceki aylar için zaman girişi yapılamaz.');
field.setValue(null); // Değeri sıfırlayarak log girişini engelle
}
});
}