Run Rule for Personal Phone Number Update

Can anyone please help with run rule for below use case ?

Personal Number from Workday to be updated in mobilePhone identity attribute with below logic for only India and Taiwan Users. Check the identity mapping config for mobilePhone identity attribute and implement below logic without impacting the existing logic

a. For any new users where mobilePhone identity attr is null (Oldvalue is null)

i. mobilePhone identity attribute should be updated with Personal Number from Workday
ii. optInApplication should be set with value “IIQ_BCP:TRUE|IIQ_AD:FALSE”

b. For existing users where oldValue of mobileNumber is NUMBER1/NULL and newValue of mobileNumber is NUMBER2 (Difference in old and new value)

i. mobilePhone identity attribute should be updated with new Personal Number from Workday

Hi @Mani_AMAT,

can you explain where you are having problems?

Can you please validate the rule once which I wrote ?

I have written below Identity Attribute Rule and getting this error - Exception running rule: BeanShell script error: bsh.EvalError: Sourced file: inline evaluation of: import sailpoint.object.Link; import sailpoint.object.Identity; import sailpoint . . . '' : Attempt to resolve method: getAttribute() on undefined variable or class name: identity : at Line: 7 : in file: inline evaluation of: import sailpoint.object.Link; import sailpoint.object.Identity; import sailpoint . . . ‘’ : identity .getAttribute ( “employeeId” )
BSF info: Rule_AMAT_Personal_Phone_Number_Update at line: 0 column: columnNo

<?xml version='1.0' encoding='UTF-8'?>

The log object associated with the SailPointContext.



The identity being evaluated.
   </Description>
  </Argument>
  <Argument name="context">
    <Description>

A sailpoint.api.SailPointContext object that can be used to query the database if necessary.



The application where the activity was generated.

An application may have more then one data source.



The activity object that was normalized by the data source and that we are trying to correlate back to one of our Identities.





A string that represents the link’s identity attribute.



import sailpoint.object.Link; import sailpoint.object.Identity; import sailpoint.tools.Util; import java.util.List; String formattedPhone = null; // To check for Single Identity if (identity != null && "170845".equalsIgnoreCase((String)identity.getAttribute("employeeId"))){ //if (identity != null) { List links = identity.getLinks(); if (links != null && !links.isEmpty()) { for (Link link : links) { if ("HR-Workday-WebService".equals(link.getApplicationName())) { String Country = link.getAttribute("COUNTRY"); String phone = link.getAttribute("Personal_Phone__c"); if (!Util.isEmpty(phone) && !Util.isEmpty(Country)) { // Remove unwanted characters phone = phone.replaceAll("[\\s()-]", ""); // Logic for INDIA if ("IND".equalsIgnoreCase(Country) && phone.length() >= 10) { formattedPhone = phone.substring(0, 3) + "-" + phone.substring(3); } // Logic for Taiwan else if ("TWN".equalsIgnoreCase(Country) && phone.length() >= 10) { formattedPhone = phone.substring(0, 4) + "-" + phone.substring(4); } if (!Util.isEmpty(formattedPhone)) { // CASE 1: If it's a new user if (oldValue == null) { identity.setAttribute("optInApplication", "IIQ_BCP:TRUE|IIQ_AD:FALSE"); return formattedPhone; } // CASE 2: If it's a existing user if (!oldValue.equals(formattedPhone)) { return formattedPhone; } } } } } }
   context.startTransaction();
   context.saveObject(identity);
   context.commitTransaction();
}

//}

I am trying the rule with Identity Refresh

Gettting this error agian

Exception running rule: BeanShell script error: bsh.ParseException: Parse error at line 16, column 30. Encountered: ; BSF info: Rule_AMAT_Personal_Phone_Number at line: 0 column: columnNo

This
Encountered: ;
leads me to believe you have a function call with the incorrect number of arguments. Essentially it’s saying that it came across a semi-colon before it expected to. I can’t really reference the line numbers since the code displayed is run together.

I am getting this error for Identity Attribute Rule - error declaring bean: identity : bsh.EvalError: Can’t assign sailpoint.object.Identity to java.lang.String : at Line: -1 : in file: :

Hello @Mani_AMAT,

Based on your latest error, this one states that EntityValue is wrongly stated. I can’t tell from my end what exactly is the issue, however my advice is to go over the sintax within your java code. Do a debugging approach

import sailpoint.object.Link;
import sailpoint.object.Identity;
import sailpoint.tools.Util;
import java.util.List;

String formattedPhone = null;

// Ensure identity object exists
if (identity != null && "170845".equalsIgnoreCase((String)identity.getAttribute("employeeId"))) {
    
    List links = identity.getLinks();

    if (links != null && !links.isEmpty()) {
        for (Link link : links) {
            if ("HR-Workday-WebService".equals(link.getApplicationName())) {
                
                String country = link.getAttribute("COUNTRY");
                String phone = link.getAttribute("Personal_Phone__c");

                if (!Util.isEmpty(phone) && !Util.isEmpty(country)) {
                    // Clean up phone string
                    phone = phone.replaceAll("[\\s()-]", "");

                    // Format for India
                    if ("IND".equalsIgnoreCase(country) && phone.length() >= 10) {
                        formattedPhone = phone.substring(0, 3) + "-" + phone.substring(3);
                    }
                    // Format for Taiwan
                    else if ("TWN".equalsIgnoreCase(country) && phone.length() >= 10) {
                        formattedPhone = phone.substring(0, 4) + "-" + phone.substring(4);
                    }

                    if (!Util.isEmpty(formattedPhone)) {
                        // Set another attribute if needed (but this rule must return ONE value)
                        // identity.setAttribute("optInApplication", "IIQ_BCP:TRUE|IIQ_AD:FALSE");

                        return formattedPhone;
                    }
                }
            }
        }
    }
}

return null;

Check this rule and modify as per your requirements also check if you have "employeeId" defined as an attribute and mapped properly