Phaded
Phaded

Reputation: 109

Azure B2C Preconditions and checking for empty strings

Is there a way, in the preconditions step of an orchestrationstep to check if a claim is set to empty string?

I've tried the below and it doesn't work, it never executes the SkipThisOrchestrationStep

              <Precondition Type="ClaimEquals" ExecuteActionsIf="true">
                <Value>readOnlyPhone</Value>
                <Value></Value>
                <Action>SkipThisOrchestrationStep</Action>
              </Precondition>
            </Preconditions>

Also I have also attempted to use ClaimExists and that does not work either

            <Preconditions>
              <Precondition Type="ClaimsExists" ExecuteActionsIf="false">
                <Value>readOnlyPhone</Value>
                <Action>SkipThisOrchestrationStep</Action>
              </Precondition>
            </Preconditions>

Background, the claim is being set by a RestfulProvider Technical Profile, and the API will return in the payload "phoneNumber": ""

Upvotes: 3

Views: 2866

Answers (2)

Juliyanage Silva
Juliyanage Silva

Reputation: 2699

There is a shorter way of doing this. You can add an output claim having a default value of "" for strings in previous technical profile:

I did this in AAD-UserReadUsingObjectId

<TechnicalProfile Id="AAD-UserReadUsingObjectId">
                <Metadata>
                    <Item Key="Operation">Read</Item>
                    <Item Key="RaiseErrorIfClaimsPrincipalDoesNotExist">true</Item>
                </Metadata>
                <IncludeInSso>false</IncludeInSso>
                <InputClaims>
                    <InputClaim ClaimTypeReferenceId="objectId" Required="true"/>
                </InputClaims>
                <OutputClaims>
                    
                    <OutputClaim ClaimTypeReferenceId="extension_{your_custom_attribute}" DefaultValue=""/>
                    
                </OutputClaims>
                <IncludeTechnicalProfile ReferenceId="AAD-Common"/>
            </TechnicalProfile>

Also AAD-Common refers to meta data: extension_app_id extenstion_client_id

Upvotes: 1

Jas Suri - MSFT
Jas Suri - MSFT

Reputation: 11335

Use a compare claims transform to return a Boolean https://learn.microsoft.com/en-us/azure/active-directory-b2c/string-transformations#compareclaimtovalue

Then use a claimsEqual precondition against this Boolean.

Upvotes: 6

Related Questions