Filter to extract the links using mutiple or condition

Which IIQ version are you inquiring about?

8.4

Please share any images or screenshots, if relevant.

[Please insert images here, otherwise delete this section]

Can someone help me with the below filters/code, on below requirement.

I need to get the of list Identities or Links, who has Workday Link and on the company code is of or (a, b, c, e). Company Code attribute is there on the Workday Link level.

Could you please help with sample code.

@sidharth_tarlapally, @sauvee , @enistri_devo , @kjakubiak

Hi @san1385

Please find the code below:

QueryOptions qo = new QueryOptions();
List andFilter= new ArrayList();
Filter.add(Filter.eq("application.name",<yourappName>));
Filter.like("companyCode", “a“, Filter.MatchMode.START);
qo.addFilter(Filter.and(andFilter));

Iterator itx = context.search(Link.class, qo)

Thanks

Do we need, make Workday Schema Attribute COMPANY_CODE as searchable? Then only will it Work. I have tried as, below and facing below error.

QueryOptions qo = new QueryOptions();
List andFilter= new ArrayList();
Filter.add(Filter.eq(“application.name”,“Workday”));
Filter.eq(“COMPANY_CODE”, “xcv”);
qo.addFilter(Filter.and(andFilter));

Iterator itx = context.search(Link.class, qo);

NOTE:COMPANY_CODE is WORKDAY application exact schema attribute

Exception running rule: BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: ``import java.math.BigInteger; import java.lang.StringBuilder; import java.tex . . . ‘’ : Error in method invocation: Static method add(sailpoint.object.Filter$LeafFilter) not found in class’sailpoint.object.Filter’

Could you please share your full code with me?

Thanks

Is COMPANY_CODE an extended attribute, or is it a schema of the Workday app?

import sailpoint.object.Filter;

import sailpoint.object.QueryOptions;

import java.util.List;

QueryOptions qo = new QueryOptions();
List andFilter= new ArrayList();
Filter.add(Filter.eq(“application.name”,“Workday”));
Filter.eq(“COMPANY_CODE”,“0617”);
qo.addFilter(Filter.and(andFilter));

Iterator itx = context.search(Link.class,qo);
while (itx.hasNext()) {
Link link = (Link) itx.next();
log.error(“Found link: " + link.getNativeIdentity() +
" COMPANY_CODE=” + link.getAttribute(“COMPANY_CODE”));
}

COMPANY_CODE is a Schema Attribute of WOrkday.

When you create a Filter and do a search, your filter gets translated to a Hibernate query, which gets translated to SQL. In order for something to be searchable, you have to map it to a database column.

If Workday is an authoritative source, I would probably promote the attribute to an Identity attribute and search it on the Identity. If it is not, I’m not sure what I’d do. I’d prefer to avoid adding application-specific attributes to my database.

Can you share more about why you need specific company codes?

Depending on what you are doing, defining an IT role for the people with any of the desired company codes may be a good approach.

For those specfic company codes, on a particular day/specific day, we need launch a workflow, to update some attributes, which is like a hadoc task.

hi @reddyc9
Not an IIQ Guy :upside_down_face:
@Harikrishna_06 can u help ?

1 Like
List<Identity> matchingIdentities = new ArrayList<>();
        List<String> companyCodes = List.of("a", "b", "c", "e");

        // Get all identities
        List<Identity> allIdentities = context.getObjects(Identity.class);

        for (Identity identity : allIdentities) {
            // Get the links for the identity
            List<Link> links = identity.getLinks();

            for (Link link : links) {
                // Check if the link is a Workday link
                if (link instanceof WorkdayLink) {
                    WorkdayLink workdayLink = (WorkdayLink) link;

                    // Check if the company code matches
                    String companyCode = workdayLink.getCompanyCode();
                    if (companyCodes.contains(companyCode)) {
                        matchingIdentities.add(identity);
                        break; // No need to check other links for this identity
                    }
                }
            }
        }


1 Like

Thank You, rakesh. the code which you shared is working, but we need to load all identities and check the link. What we did is we have created Identity attribute for those and mapped the values from workday, then we were able to write the filter easily.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.