Time Card locking

Burhan2
Tera Contributor

Hii,We had a requirement to lock the time cards for previous week after certain day in the current week.For ex previous week time card can't be submitted by the user after wednesday of current week.

We implemented that using business rule and it is working as expected.But we are confuse on one part if suppose user forgets to fill timecard of previous how will he able to fill that after demanding access from timecard_admin so how to implement that like we can't deactivate br for every user how can we implement that please help us...?

1 ACCEPTED SOLUTION

Hello @Burhan 

You just need to create a field of true/false type on time_card table. In dictionary set the default value to false

In your BR condition just check like below. In my case field name is different

YOUR BR CODE WILL BE AS IT IS.

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

View solution in original post

13 REPLIES 13

Mahendra RC
Mega Sage

Hello Burhan,

To implement this solution you can create a new field of type checkbox named as for example Allow submission and if the user has not submitted the timesheet for previous than they can check with someone say timecard_admin. so timecard_admin user can check the Allow submission checkbox and in the BR you can check that if Allow submission is checked for any record then the BR should not run.

So for the records where timecard_admin will check that checkbox the BR will not run and the users will be able to submit the timecard for that particular record.

Please mark my respsone as helpful/correct, if it answer your question.

Thank

Hii @Mahendra thanks for reply so the field will be create on the time_card form? Also ill share my br can u show me a demo of how it will be done

(function executeRule(current, previous /*null when async*/ ) {    var weekStartDate = current.getValue("week_starts_on");    var validDate = new GlideDateTime(weekStartDate);
    validDate.addDays(+2);    var currentTimeGDT = new GlideDateTime();
    currentTimeGDT.addDays(-7);    var dur = new GlideDuration();
    dur = GlideDateTime.subtract(currentTimeGDT, validDate);
    var days = dur.getDayPart();    if (parseInt(days) <= 0) {
        if (days == 0) {
            var currentTimeGDT1 = new GlideDateTime();            var NowTime = currentTimeGDT1.getDisplayValue();
            var NowTimeGDT = new GlideDateTime(NowTime);
            var NumericNowTime = NowTimeGDT.getNumericValue();            var blockTime = currentTimeGDT1.getDate() + " 10:00:00";
            var blockTimeGDT = new GlideDateTime(blockTime);
            var blockTimeNumeric = blockTimeGDT.getNumericValue();            if (NumericNowTime < blockTimeNumeric) {                return;            }        }
        gs.addErrorMessage("Timesheet for " + current.getValue("week_starts_on") + " week is freezed and not allow to be submitted.");
        current.setAbortAction(true);    }
})(current, previous);

Hello @Burhan 

You just need to create a field of true/false type on time_card table. In dictionary set the default value to false

In your BR condition just check like below. In my case field name is different

YOUR BR CODE WILL BE AS IT IS.

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

Thanks @Mahendra will perform this just a last ques u said this field will be visible to time_card admin only in form so how that will be possible ?