Transform to set value of Identity attribute based on criteria

Don’t know if anyone has ever accomplished this but I am trying to create a transform to set the value to say Yes of an identity attribute where say the job code equals one that is in a predefined list or if it equals one that is in a predefined list and then the location is a specific location. I have thought of a using a conditional and a lookup but not sure if that would work

Hi David, You can try transform like below.

    {"name": "Set Value",
    "type": "static",
    "attributes": {
        "JobCode": {
            "attributes": {
                "name": "jobcode"
            },
            "type": "identityAttribute"
        },
    "YesString": {
        "type": "static",
            "attributes": {
                "value": "Yes"
            }
        },
    "NoString": {
        "type": "static",
            "attributes": {
                "value": "Your Default No String Here"
            }
        },    
    "location": {
        "attributes": {
            "name": "location"
        },
        "type": "identityAttribute"
    },
        
        "value": "#if(($JobCode == 'A' || $JobCode == 'B' || $JobCode=='C')) && ($location=='Your_location'))$YesString#else$NoString#end"
    }
}

Add your available list of Jobcode in this part, ($JobCode == 'A' || $JobCode == 'B' || $JobCode=='C')

Thanks.

Thank you, I have over 200 jobs codes that I need to look at, how would you put all those into a list and look at the list. For instance a list of 20 job codes the identity attribute would be set to yes if it equaled one of those job code and location was say Location1, but then I want to set that attribute to yes if it was one of the other job codes

Thank you very much for the assistance, I did add a lookup table in the transform

“name”: “Set Value”,
“type”: “static”,
“attributes”: {
“Prod”: {
“attributes”: {
“name”: “prod”
},
“type”: “identityAttribute”
},
“processlevel”: {
“attributes”: {
“name”: “processLevel”
},
“type”: “identityAttribute”
},
“JobCode”: {
“attributes”: {
“name”: “jobCode”
},
“type”: “identityAttribute”
},
“systemwidecodes”: {
“type”: “lookup”,
“attributes”: {
“table”: {
“6”: “6”,
“21”: “21”,
“39”: “39”,
“42”: “42”,
“default”: “blank”
}
}
},
“FHCode”: {
“type”: “lookup”,
“attributes”: {
“table”: {
“209”: “209”,
“450”: “450”,
“452”: “452”,
“default”: “blank”
}
}
},
“YesString”: {
“type”: “static”,
“attributes”: {
“value”: “Yes”
}
},
“NoString”: {
“type”: “static”,
“attributes”: {
“value”: “No”
}
},
“value”: “#if(($JobCode == $systemwidecodes) || ($JobCode == $FHCode) && ($processlevel==‘2005’))$YesString#else$NoString#end”
},
“internal”: false

Hi David, I was working on an answer for you. Have you tested your transform, and if so, was it successful?

You can either use static transform which @kdfreeman given or a lookup transform. But either way you need to include all the job codes. If you think it is going to be huge then, you may need to think about the identity attribute rule. By looking at your count over 200 can be handled in transform.

Below is a sample code to handle the same using Lookup with empty value.

{
        "name": "Lookup JobCode",
        "type": "lookup",
        "attributes": {
            "input": {
                "attributes": {
                    "values": [
                        {
                            "attributes": {
                                "name": "jobCode"
                            },
                            "type": "identityAttribute"
                        },
                        "none"
                    ]
                },
                "type": "firstValid"
            },
            "table": {
                "default": "No",
                "JC1": "Yes",
				"JC2": "No",
                "none": "No"
            }
        },
        "internal": false
    }

Hi David,
I found your problem interesting, so I built and tested this transform in my sandbox on a test IdentityProfile with just 12 Identities so I could apply the changes quickly. I used costCenterId in lieu of Job Code, and location for location, but you can adapt this transform quickly to your purposes.

jobCodeMatches and locationMatches are two lookup transforms for which I specified that the input be an identityAttribute.

Those serve as variables for the static transform using a conditional. I recognize how ugly those conditions are, but I did first try with the outer transform’s value being #if($jobCodeMatches && $locationMatches)Yes#{else}No#end, but it didn’t work. Somehow, the string "false" is not being coerced to a Boolean type, and is being evaluated as a non-empty string.

{
	"attributes": {
		"jobCodeMatches": {
			"attributes": {
				"table": {
					"C120": "true",
					"J150": "true",
					"D250": "true",
					"default": "false"
				},
				"input": {
					"type": "static",
					"attributes": {
						"value": "$identity.getStringAttribute('costCenterId')"
					}
				}
			},
			"type": "lookup"
		},
		"locationMatches": {
			"attributes": {
				"table": {
					"Virtual - US": "true",
					"New York": "true",
					"Washington": "true",
					"default": "false"
				},
				"input": {
					"type": "static",
					"attributes": {
						"value": "$identity.getStringAttribute('location')"
					}
				}
			},
			"type": "lookup"
		},
		"value": "#if($jobCodeMatches=='true' && $locationMatches=='true')Yes#{else}No#end"
	},
	"type": "static",
	"name": "Set Value - Static+Lookup Example - VS.AP"
}

Here are the search results showing that the conditional logic works.

And yes, I just used the transform to fill the Identity Attribute ‘directoryAlias’, because it was available and easy to map onto.

1 Like

Yes I tested it in my Sandbox environment and it worked for me. Thank you for response

1 Like