Get Working Dates from Transact using T24 Session

Last updated: 2023-11-16

This snippet can be used in any routine to get working dates from Transact using "com.temenos.t24.api.system.Session"

package com.temenos.t24;

import com.temenos.api.TStructure;
import com.temenos.t24.api.complex.eb.templatehook.TransactionContext;
import com.temenos.t24.api.hook.system.RecordLifecycle;
import com.temenos.t24.api.records.company.CompanyRecord;
import com.temenos.t24.api.records.dates.DatesRecord;
import com.temenos.t24.api.system.DataAccess;
import com.temenos.t24.api.system.Session;

/**
 * @author Danish The Techie
 */
public class GetDateFromTransact extends RecordLifecycle {
    
    @Override
    public void defaultFieldValues(String application, String currentRecordId, TStructure currentRecord,
            TStructure unauthorisedRecord, TStructure liveRecord, TransactionContext transactionContext) {
        
        DataAccess da = new DataAccess(this);
        Session t24Session = new Session(this);
        
        //Getting Today Date using T24Session
        String todayDate = t24Session.getCurrentVariable("!TODAY");
        
        //getting current company record using TSession
        CompanyRecord companyRecord = t24Session.getCompanyRecord();
        String companyCode = companyRecord.getCoCode();
        
        //Get Current Working Dates using company Id from DATES Table
        DatesRecord dateRec = new DatesRecord(da.getRecord("DATES", companyCode));
        String lastWorkingDay = dateRec.getLastWorkingDay().getValue();
        String currentWorkingDay = dateRec.getNextWorkingDay().getValue();
        String workingDay = dateRec.getToday().getValue();
        
    }

}