Validation for different information in the transform

Hi everyone, I need help.

I’m developing a validation function in my transformation. I need to validate whether the “lifecycleState” attribute is different from 1, 2, or 3 and whether the “titleException” attribute contains the value “SUPERINTENDENT.”

But it’s not working correctly.

my transform
{
“id”: “0000000000”,
“name”: “Set LifeCycleStatus”,
“type”: “static”,
“attributes”: {
“codigoSituacao”: {
“type”: “lookup”,
“attributes”: {
“input”: {
“type”: “firstValid”,
“attributes”: {
“values”: [
{
“type”: “accountAttribute”,
“attributes”: {
“sourceName”: “source - DB”,
“attributeName”: “CODIGO_SITUACAO”
}
},
{
“type”: “static”,
“attributes”: {
“value”: “-”
}
}
]
}
},
“table”: {
“0”: “terminated”,
“1”: “active”,
“2”: “terminated”,
“3”: “terminated”,
“4”: “terminated”,
“5”: “leaveofabsence”,
“6”: “leaveofabsence”,
“7”: “leaveofabsence”,
“8”: “leaveofabsence”,
“9”: “vacation”,
“10”: “leaveofabsence”,
“11”: “leaveofabsence”,
“12”: “leaveofabsence”,
“13”: “leaveofabsence”,
“14”: “terminated”,
“15”: “active”,
“16”: “leaveofabsence”,
“17”: “leaveofabsence”,
“18”: “leaveofabsence”,
“19”: “leaveofabsence”,
“20”: “leaveofabsence”,
“21”: “leaveofabsence”,
“22”: “leaveofabsence”,
“23”: “leaveofabsence”,
“24”: “leaveofabsence”,
“25”: “leaveofabsence”,
“26”: “terminated”,
“27”: “terminated”,
“28”: “terminated”,
“29”: “terminated”,
“30”: “leaveofabsence”,
“31”: “active”,
“32”: “leaveofabsence”,
“33”: “active”,
“34”: “terminated”,
“35”: “terminated”,
“36”: “terminated”,
“37”: “terminated”,
“38”: “leaveofabsence”,
“39”: “leaveofabsence”,
“40”: “leaveofabsence”,
“41”: “leaveofabsence”,
“42”: “leaveofabsence”,
“43”: “leaveofabsence”,
“44”: “terminated”,
“45”: “leaveofabsence”,
“46”: “leaveofabsence”,
“47”: “leaveofabsence”,
“48”: “terminated”,
“49”: “leaveofabsence”,
“51”: “terminated”,
“52”: “terminated”,
“53”: “terminated”,
“54”: “leaveofabsence”,
“55”: “terminated”,
“56”: “terminated”,
“57”: “terminated”,
“58”: “terminated”,
“59”: “terminated”,
“61”: “terminated”,
“91”: “leaveofabsence”,
“92”: “leaveofabsence”,
“95”: “leaveofabsence”,
“96”: “leaveofabsence”,
“99”: “terminated”,
“100”: “leaveofabsence”,
“101”: “leaveofabsence”,
“102”: “leaveofabsence”,
“103”: “leaveofabsence”,
“104”: “leaveofabsence”,
“105”: “leaveofabsence”,
“106”: “leaveofabsence”,
“107”: “leaveofabsence”,
“108”: “leaveofabsence”,
“109”: “leaveofabsence”,
“110”: “leaveofabsence”,
“111”: “leaveofabsence”,
“112”: “leaveofabsence”,
“113”: “leaveofabsence”,
“114”: “leaveofabsence”,
“115”: “leaveofabsence”,
“116”: “leaveofabsence”,
“117”: “terminated”,
“118”: “leaveofabsence”,
“119”: “leaveofabsence”,
“120”: “leaveofabsence”,
“1001”: “leaveofabsence”,
“default”: “active”
}
}
},
“endDate”: {
“type”: “reference”,
“attributes”: {
“id”: “End Date Reached”
}
},
“codSituation”: {
“type”: “firstValid”,
“attributes”: {
“values”: [
{
“type”: “accountAttribute”,
“attributes”: {
“sourceName”: “source - DB”,
“attributeName”: “CODIGO_SITUACAO”
}
},
{
“type”: “static”,
“attributes”: {
“value”: “-”
}
}
]
}
},
“titleException”: {
“type”: “firstValid”,
“attributes”: {
“values”: [
{
“type”: “identityAttribute”,
“attributes”: {
“name”: “title”
}
},
{
“type”: “static”,
“attributes”: {
“value”: “-”
}
}
]
}
},
“lifecycleState”: {
“type”: “identityAttribute”,
“attributes”: {
“name”: “situation”
}
},
“value”: “#if($endDate == ‘demitido’ && $codSituation == ‘2’)terminated#elseif($endDate == ‘demitido’ && $codSituation == ‘3’)terminated#elseif($lifecycleState != ‘1’ || $lifecycleState !=‘2’ || $lifecycleState !=‘3’ && $titleException.contains(‘SUPERINTENDENTE’))leaveexception#{else}$codigoSituacao#end”
},
“internal”: false
}

the field “situation” is correct, but the field title does not contain “SUPERINTENDENT”

A few things:

  1. You need to format your code block correctly. It’s illegible in the above because you didn’t wrap it in a code block. Here’s what it should look like:
    "id": "0000000000",
    "name": "Set LifeCycleStatus",
    "type": "static",
    "attributes": {
        "codigoSituacao": {
            "type": "lookup",
            "attributes": {
                "input": {
                    "type": "firstValid",
                    "attributes": {
                        "values": [
                            {
                                "type": "accountAttribute",
                                "attributes": {
                                    "sourceName": "source - DB",
                                    "attributeName": "CODIGO_SITUACAO"
                                }
                            },
                            {
                                "type": "static",
                                "attributes": {
                                    "value": "-"
                                }
                            }
                        ]
                    }
                },
                "table": {
                    "0": "terminated",
                    "1": "active",
                    "2": "terminated",
                    "3": "terminated",
                    "4": "terminated",
                    "5": "leaveofabsence",
                    "6": "leaveofabsence",
                    "7": "leaveofabsence",
                    "8": "leaveofabsence",
                    "9": "vacation",
                    "10": "leaveofabsence",
                    "11": "leaveofabsence",
                    "12": "leaveofabsence",
                    "13": "leaveofabsence",
                    "14": "terminated",
                    "15": "active",
                    "16": "leaveofabsence",
                    "17": "leaveofabsence",
                    "18": "leaveofabsence",
                    "19": "leaveofabsence",
                    "20": "leaveofabsence",
                    "21": "leaveofabsence",
                    "22": "leaveofabsence",
                    "23": "leaveofabsence",
                    "24": "leaveofabsence",
                    "25": "leaveofabsence",
                    "26": "terminated",
                    "27": "terminated",
                    "28": "terminated",
                    "29": "terminated",
                    "30": "leaveofabsence",
                    "31": "active",
                    "32": "leaveofabsence",
                    "33": "active",
                    "34": "terminated",
                    "35": "terminated",
                    "36": "terminated",
                    "37": "terminated",
                    "38": "leaveofabsence",
                    "39": "leaveofabsence",
                    "40": "leaveofabsence",
                    "41": "leaveofabsence",
                    "42": "leaveofabsence",
                    "43": "leaveofabsence",
                    "44": "terminated",
                    "45": "leaveofabsence",
                    "46": "leaveofabsence",
                    "47": "leaveofabsence",
                    "48": "terminated",
                    "49": "leaveofabsence",
                    "51": "terminated",
                    "52": "terminated",
                    "53": "terminated",
                    "54": "leaveofabsence",
                    "55": "terminated",
                    "56": "terminated",
                    "57": "terminated",
                    "58": "terminated",
                    "59": "terminated",
                    "61": "terminated",
                    "91": "leaveofabsence",
                    "92": "leaveofabsence",
                    "95": "leaveofabsence",
                    "96": "leaveofabsence",
                    "99": "terminated",
                    "100": "leaveofabsence",
                    "101": "leaveofabsence",
                    "102": "leaveofabsence",
                    "103": "leaveofabsence",
                    "104": "leaveofabsence",
                    "105": "leaveofabsence",
                    "106": "leaveofabsence",
                    "107": "leaveofabsence",
                    "108": "leaveofabsence",
                    "109": "leaveofabsence",
                    "110": "leaveofabsence",
                    "111": "leaveofabsence",
                    "112": "leaveofabsence",
                    "113": "leaveofabsence",
                    "114": "leaveofabsence",
                    "115": "leaveofabsence",
                    "116": "leaveofabsence",
                    "117": "terminated",
                    "118": "leaveofabsence",
                    "119": "leaveofabsence",
                    "120": "leaveofabsence",
                    "1001": "leaveofabsence",
                    "default": "active"
                }
            }
        },
        "endDate": {
            "type": "reference",
            "attributes": {
                "id": "End Date Reached"
            }
        },
        "codSituation": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "accountAttribute",
                        "attributes": {
                            "sourceName": "source - DB",
                            "attributeName": "CODIGO_SITUACAO"
                        }
                    },
                    {
                        "type": "static",
                        "attributes": {
                            "value": "-"
                        }
                    }
                ]
            }
        },
        "titleException": {
            "type": "firstValid",
            "attributes": {
                "values": [
                    {
                        "type": "identityAttribute",
                        "attributes": {
                            "name": "title"
                        }
                    },
                    {
                        "type": "static",
                        "attributes": {
                            "value": "-"
                        }
                    }
                ]
            }
        },
        "lifecycleState": {
            "type": "identityAttribute",
            "attributes": {
                "name": "situation"
            }
        },
        "value": "#if($endDate == 'demitido' && $codSituation == '2')terminated#elseif($endDate == 'demitido' && $codSituation == '3')terminated#elseif($lifecycleState != '1' || $lifecycleState !='2' || $lifecycleState !='3' && $titleException.contains('SUPERINTENDENTE'))leaveexception#{else}$codigoSituacao#end"
},
"internal": false
}
  1. You should try splitting your logic up into separate transforms to make sure each component works first, then combine them into one transform. I typically would make a separate Identity Attribute and a separate transform for each of the variables in my sandbox environment to make sure they’re all evaluating as expected.
  2. You should try to avoid referencing Identity Attributes in transforms if possible. They are not necessarily evaluated in the same order every time, so you could end up in situations where the referenced Identity Attribute is updated after the transformed attribute, so the transform is using the old value to evaluate it.
1 Like

Hello Guilherme,

There’s an attention point in your code, where you are validating the lifecycle code, you need to validate if the lifecycle code 3 and the title contains superintendente, or you need to validate if the lifecycle code is 1, 2 or 3 and the title contains superintendente?

And if the attribute is wrong in the identity, you need to find a default value that all “superintendete” has, like “superin”

Pay attention in the static variables defined inside the static, that is in referente with another transform

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