How to compare integer in Precondition for B2C Custom Policy? Also how to Convert int to string?
Strap in, because this one is a doozy.
Problem Statement: I want to read user id from our SQL DB, and store it as a custom attribute in B2C. If it exists in B2C, read from custom attribute and never hit SQL DB.
I am looking for a way to compare an custom attribute integer claim using the ClaimEquals Precondition. ClaimEquals only works for strings or booleans, so in order to use this type, I first need to turn my integer claim into a string. Although, the only ClaimsTransformation offered for number -> string is ConvertNumberToStringClaim which only supports long -> string. Although, on B2C, long isn't even offered as a type for custom attributes. So what I tried to do is I defined my custom attribute as an int, and just define the extension_userId in the custom policy as a long. Although, this initially worked, after attempting to re-upload the custom policies, it throws a syntax error on the final step telling me that when I am forced to default the value, that 0 is a type mis-match with long. So in order to get this to work, I have to revert certain key changes, upload the policies out of order, and then re-upload the extensions policy. This technically works but is the worst thing I've ever done in programming.
So my question is,
How do you compare an integer in a Precondition using Custom Policies? and How do you convert an int to a string?
Thanks
Relevant Code:
<ClaimType Id="Id">
<DisplayName>Id</DisplayName>
<DataType>long</DataType> <!-- Actually an integer -->
<AdminHelpText>extension_Id</AdminHelpText>
<UserHelpText>extension_Id</UserHelpText>
</ClaimType>
<ClaimType Id="extension_Id">
<DisplayName>extension_Id</DisplayName>
<DataType>long</DataType> <!-- Actually an integer -->
<AdminHelpText>extension_Id</AdminHelpText>
<UserHelpText>extension_Id</UserHelpText>
</ClaimType>
<ClaimsTransformation Id="CopyId_string" TransformationMethod="ConvertNumberToStringClaim">
<InputClaims>
<InputClaim ClaimTypeReferenceId="Id" TransformationClaimType="inputClaim"/>
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="Id_string" TransformationClaimType="outputClaim"/>
</OutputClaims>
</ClaimsTransformation>
<!-- If custom attribute doesn't exist, read from API -->
<OrchestrationStep Order ="5" Type="InvokeSubJourney">
<Preconditions>
<!-- If Id > 0, skip this orchestration step-->
<Precondition Type="ClaimEquals" ExecuteActionsIf="false">
<Value>MMId_string</Value>
<Value>0</Value>
<Action>SkipThisOrchestrationStep</Action>
</Precondition>
</Preconditions>
<JourneyList>
<Candidate SubJourneyReferenceId="read-from-api"/>
</JourneyList>
</OrchestrationStep>
PS: I would just use ClaimsExist, but am forced to default the value because there is no null checking.