How to remove leading zeros using the expression builder in entra ID

Ghebremichael, Rahwa 45 Reputation points
2025-01-09T15:53:47.3966667+00:00

Hi All,

We are working on Workday to on-premise AD integration through entra provisioning service solution. We need to remove leading zeros from the "employeeId" attribute because Workday has leading zeros present but on-premise AD doesn’t have leading zeros. My goal is to configure the mapping of the "employeeId" attribute so that only leading zeros are removed during the synchronization.

I tried setting the mapping type to "Expression mapping "and using regular expressions to remove the leading zeros, but my attempts haven't worked as expected.

Here are the expressions I tried:

  1. Replace([employeeId], "^0+", "") I expected this to remove only the leading zeros, but it didn't work.
  2. Replace([employeeId], "0", "", "", "", "", "") This removed all zeros, but I need to keep non-leading zeros intact.
  3. Replace([employeeId], "^0+", "", "", "", "", "") This also didn’t work as intended and returned the same result.

How can I correctly remove only the leading zeros from the "employeeId" attribute during the sync to on-premise AD? Thanks.

Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

Accepted answer
  1. Chetan Desai 1,066 Reputation points Microsoft Employee
    2025-01-16T22:16:10.45+00:00

    Use this expression mapping function to remove the leading zeros.

    So, if your WorkerID is 0000A2309, then this expression will emit A2309.

    Replace([WorkerID], , "(?<leadingZeros>^0+)(?<actualValue>[a-zA-Z0-9]+)", , "${actualValue}", ,)
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sakshi Devkante 4,395 Reputation points Microsoft External Staff Moderator
    2025-01-15T17:51:30.1233333+00:00

    Hello @Ghebremichael, Rahwa

    Thank you for posting your query on Microsoft Q&A.
    User's image

    Refer document: https://learn.microsoft.com/en-us/entra/identity/app-provisioning/functions-for-customizing-application-data

    Please note that if you are creating an expression, it will not remove the extra zero from the attribute originating from Workday. The Expression Builder is not designed to address this issue of eliminating the extra zero.

    Reviewing standard regular expression instructions can be useful if you're unclear about the regular expression syntax supported by Workday or Azure AD. You may test and debug your regular expressions using websites such as regex101: build, test, and debug regex

    Understand how expression builder works with Application Provisioning in Microsoft Entra ID - Microsoft Entra ID | Microsoft Learn

    To guarantee that just the leading zeros are eliminated, this slightly altered expression matches one or more zeros at the beginning of the string

    Replace([WorkerID], , "(?<leadingZeros>^0+)(?<actualValue>[a-zA-Z0-9]+)", , "${actualValue}", ,)

    I hope this clarifies things. Please contact us if you have any additional questions.

    If this answers your query, do click Accept Answer and Yes for "Was this answer helpful". And, if you have any further query do let us know.

    Best regards,

    Sakshi Devkante

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.