Identity Exists check for Identity attribute cloud rule

Hi All,

We’ve a requirement to calculate cloudlifecycle state attribute for that our architect asked to create cloud rule, Where I’m able achieve most of the scenario except one edge scenario,

Edge Scenario 1:

If identity Hr status is terminated and end date is future date and state date is not future date here expected outcome is active This applicable for Identity that already exists if new identity comes this should return null.

For this I used

String hasUidAttribute = identity.getAttribute(“uid”);
String hasUid = hasUidAttribute ! = null ? hasUidAttribute.trim(): null;

int count =
countIdentitiesBySearchableIdentityAttribute(“uid”, “Equals” , hasUid);

If (((endDate.isAfter(today)) && (!(startDate.isAfter(today)))) && (hrStatus.equalsIgnoreCase(“Terminated”)))
{
If (count > 0)
{
return “active”;
}
else {
return null;
}
}

Here for both identity exists and new identity created provide same result as active.

Can anyone help to look this code and correct me if I’m missing something?

@vasanthrajsp29 You can use transforms to achieve this for the already existing users.

For new users, what should be the life cycle state?

1 Like

Hi @anneragh,

Agreed but client architect do not want this transform they need only cloudrule for calculating LCS.

New user there should not be any life cycle state it should be null.

Regards,
Vasanth

Hello,

I have seen you code snippet.

Now, the out of the nox Java Function which you are using for Date Comparison is : isAfter().

This function requires data in a particular format. Therefore, the input string has to be converted into LocalDate foomat and then, you can use the isAfter() function.

Refer the below code example and if you dont have the logic as per below, then, perform the required changes and then, retry.

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class DateComparison {
    public static void main(String[] args) {
        
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        
        String startDateStr = "2023-09-15";  // Example value
        String endDateStr = "2024-10-05";    // Example value

        
        LocalDate startDate = LocalDate.parse(startDateStr, formatter);
        LocalDate endDate = LocalDate.parse(endDateStr, formatter);

        
        LocalDate today = LocalDate.now();

        
        if (endDate.isAfter(today) && !startDate.isAfter(today)) {
            System.out.println("endDate is after today's date and startDate is not after today's date.");
        } else {
            System.out.println("Dates do not satisfy the condition.");
        }
    }
}

Thank You,

Regards,
Rohit Wekhande.

1 Like

Hi @rohit_wekhande,

I used the isAfter() to calculate LCS, Confusion here is to check identity exists or not check by using
int count =
countIdentitiesBySearchableIdentityAttribute(“uid”, “Equals” , hasUid);
Need to find where I’m making mistakes.

Regards,
Vasanth