Display name update challenges

We currently differentiate usernames between contractors and FTEs, now we are being asked to mark a subset of contractors with a different identifier in their display name. I have a valid JSON for the work but I am getting a template rendering error when I attempt to move the transform into prod. See below. Do I have a syntax error or am i overlooking something else?

{
    "id": "afec2c4c-fcec-4ff7-9531-19f9ce2fcbe6",
    "name": "setDisplayNameWorkday",
    "type": "static",
    "attributes": {
        "displayName": {
            "attributes": {
                "attributeName": "WORKER_NAME",
                "sourceName": "Workday Auth Source"
            },
            "type": "accountAttribute"
        },
        "userType": {
            "attributes": {
                "attributeName": "EMPLOYEE_OR_CONTRACTOR__c",
                "sourceName": "Workday Auth Source"
            },
            "type": "accountAttribute"
        },
        "costCenterDisplayName": {
            "attributes": {
                "attributeName": "costCenterDisplayname",
                "sourceName": "Workday Auth Source"
            },
            "type": "accountAttribute"
        },
        "value": "#if($userType=='Contingent Worker' && $costCenterDisplayName== '63032-Unmapped GandA Resources')${displayName} (Comet Contractor) #elseif($userType=='Contingent Worker' && $costCenterDisplayName!= '63032-Unmapped GandA Resources')${displayName} (Contractor) #{else}${displayName}#end"
    },
    "internal": false
}

Can you please share the error message string?

Hi Nathan,

It looks like there may be an issue with your quote and apostrophe symbols. Without knowing the exact error message, I can’t say for certain this will resolve your issue, but it’s a start. I have made the corrections for you; please see below.

{
    "id": "afec2c4c-fcec-4ff7-9531-19f9ce2fcbe6",
    "name": "setDisplayNameWorkday",
    "type": "static",
    "attributes": {
        "displayName": {
            "attributes": {
                "attributeName": "WORKER_NAME",
                "sourceName": "Workday Auth Source"
            },
            "type": "accountAttribute"
        },
        "userType": {
            "attributes": {
                "attributeName": "EMPLOYEE_OR_CONTRACTOR__c",
                "sourceName": "Workday Auth Source"
            },
            "type": "accountAttribute"
        },
        "costCenterDisplayName": {
            "attributes": {
                "attributeName": "costCenterDisplayname",
                "sourceName": "Workday Auth Source"
            },
            "type": "accountAttribute"
        },
        "value": "#if($userType=='Contingent Worker' && $costCenterDisplayName=='63032-Unmapped GandA Resources')${displayName} (Comet Contractor) #elseif($userType=='Contingent Worker' && $costCenterDisplayName!='63032-Unmapped GandA Resources')${displayName} (Contractor) #{else}${displayName}#end"
    },
    "internal": false
}

This is the error we are getting

Thanks for the help, the updates got me 1/2 there. I also realized I had an attribute named incorrectly. IDs are showing correctly in preview.

Does each of the accountAttributes return a value? Or would some of them be returning null?

@nathanwray it looks to me like you may be having an issue with one of the attributes from that source. It is possible the value is empty, and therefore you are receiving the error in the template due to the null value and the corresponding exception. To ensure you have null exception handling in place, you can use the firstValid transform to handle any null values. I have modified your transform to include this logic; take a look below.

You mentioned you updated some of the source attribute names in your previous reply. Make sure to do that again since I am reusing the initial code you posted which includes the incorrect source attribute names.

{
    "id": "afec2c4c-fcec-4ff7-9531-19f9ce2fcbe6",
    "name": "setDisplayNameWorkday",
    "type": "static",
    "attributes": {
        "displayName": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "WORKER_NAME",
                            "sourceName": "Workday Auth Source"
                        },
                        "type": "accountAttribute"
                    },
                    "null"
                ]
            },
            "type": "firstValid"
        },
        "userType": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "EMPLOYEE_OR_CONTRACTOR__c",
                            "sourceName": "Workday Auth Source"
                        },
                        "type": "accountAttribute"
                    },
                    "null"
                ]
            },
            "type": "firstValid"
        },
        "costCenterDisplayName": {
            "attributes": {
                "values": [
                    {
                        "attributes": {
                            "attributeName": "costCenterDisplayname",
                            "sourceName": "Workday Auth Source"
                        },
                        "type": "accountAttribute"
                    },
                    "null"
                ]
            },
            "type": "firstValid"
        },
        "value": "#if(${displayName}=='null' || ${userType}=='null' || ${costCenterDisplayName=='null')ERROR HANDLING HERE#elseif($userType=='Contingent Worker' && $costCenterDisplayName=='63032-Unmapped GandA Resources')${displayName} (Comet Contractor)#elseif($userType=='Contingent Worker' && $costCenterDisplayName!='63032-Unmapped GandA Resources')${displayName} (Contractor) #{else}${displayName}#end"
    },
    "internal": false
}

In the value attribute, you can see I added the initial “if” statement to check if any of the values are null, and if so, it will provide the Identity attribute with the value ERROR HANDLING HERE (you may want to change that as you see fit).

Let me know if this works for you. You can find more documentation on the firstValid transform at this link.

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