Hi Team,
Need some help with an LOA rule I have looking at loa_start and loa_end dates in Workday. The fields are populated in WOrkday. The before provisioning rule is configured to move to the loa ou only if a user enters the loa lcs however the rule I am using to calcualte this is not triggering the action.
In context the variable oldLCS plays a significant role in determining the lifecycle state (LCS) of an identity, particularly when considering the Leave of Absence (LOA) conditions. Here’s how oldLCS interacts with the LOA logic:
Maintaining Previous State:
The rule initializes LCS with the value of oldValue, which represents the previous lifecycle state. This means that if the conditions for LOA are not met, the rule will retain the existing state stored in oldLCS. This is crucial for ensuring that the lifecycle state does not change unnecessarily when the identity is not on leave.
LOA Condition Evaluation:
The rule checks if both loaStartStr and loaEndStr are not null. If they are present, it parses these dates and checks if the current date falls within the LOA period. If the current date is within this range, the lifecycle state is set to “loa”.
If the current date is after the LOA end date, the rule may revert the state to “newEmployee” or another relevant state, depending on the logic defined.
Fallback to Previous State:
If the identity is not currently on leave (i.e., the current date is not within the LOA period), the rule will not change the LCS from its previous value (oldLCS). This ensures that the identity’s lifecycle state remains consistent and reflects their actual employment status, rather than being incorrectly updated to “loa” when they are not on leave.
Below is the logic i am using. Would a Source configuration for this be needed in the AD source?
<![CDATA[
import sailpoint.rule.Account;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Calendar;
import java.util.Locale;
//null safe return
public String returnBlank(String value)
{
if(value == null)
{
value = "";
}
return value;
}
//keep LCS current value unless changed by the conditions below
String LCS = oldValue;
//prepare current time to compare with Workday dates
Date NOW = new Date();
//get Workday account attributes on the identity being refreshed
Account wdAccount = idn.getAccountByNativeIdentity("Workday HCM [source]", identity.getAttribute("identificationNumber"));
Map attributes = wdAccount.getAttributes();
String workerName = attributes.get("FILENUMBER");
String convertToEmployee = attributes.get("CONVERT_TO_EMPLOYEE");
String hireDateStr = attributes.get("HIREDATE");
String termDateStr = attributes.get("LAST_DAY_OF_WORK");
String loaStartStr = attributes.get("LOA_START");
String loaEndStr = attributes.get("LOA_END");
String termDateStrUpdated = termDateStr + " 12:00:00";
//logging Workday account attributes
log.debug("[AGLCS] " + workerName + " oldLCS: " + LCS);
log.debug("[AGLCS] " + workerName + " convertToEmployee: " + convertToEmployee);
log.debug("[AGLCS] " + workerName + " hireDateStr: " + hireDateStr);
log.debug("[AGLCS] " + workerName + " termDateStr: " + termDateStr);
log.debug("[AGLCS] " + workerName + " loaStartStr: " + loaStartStr);
log.debug("[AGLCS] " + workerName + " loaEndStr: " + loaEndStr);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat dateFormatTermDate = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
if(convertToEmployee != null){
LCS = "conversion";
}
else if(termDateStr != null){
//change date to local time
Date termDate = dateFormatTermDate.parse(termDateStrUpdated);
//add 18 hours to shoot for 5pm in local time
Calendar pstCal = Calendar.getInstance(TimeZone.getTimeZone("PST"));
pstCal.setTime(termDate);
pstCal.set(Calendar.HOUR_OF_DAY, 17);
Calendar pstCalNow = Calendar.getInstance(TimeZone.getTimeZone("PST"));
Date currentPST = pstCalNow.getTime();
log.debug("pstCal :" + pstCal);
log.debug("pstCalNow :" + pstCalNow);
Date termDate5PM = pstCal.getTime();
log.debug("currentPST :" + currentPST);
log.debug("termDate5PM :" + termDate5PM);
log.error("[NVLCS] " + workerName + " termDate5PM: " + termDate5PM);
if(currentPST.after(termDate5PM) || currentPST.equals(termDate5PM)){
LCS = "deprovisioning";
}
}
else if(hireDateStr != null){
//change date to local time
Date hireDate = dateFormat.parse(hireDateStr);
//add 7 days for pre hire
Calendar calendar = Calendar.getInstance();
calendar.setTime(hireDate);
calendar.add(Calendar.DATE, -7);
Date preHireDate = calendar.getTime();
if(NOW.after(preHireDate) || NOW.equals(preHireDate)){
LCS = "newEmployee";
} else {
LCS = "prehire";
}
}
else if(loaStartStr != null && loaEndStr != null) {
// Parse LOA dates
Date loaStartDate = dateFormat.parse(loaStartStr);
Date loaEndDate = dateFormat.parse(loaEndStr);
if(NOW.after(loaStartDate) && NOW.before(loaEndDate)) {
LCS = "loa";
} else if(NOW.after(loaEndDate)) {
LCS = "newEmployee";
}
}
return LCS;]]>
</Source>
</Rule>