4

Is there a way to output a claim as a hidden field (input type="hidden") so that it can be used inside custom JavaScript inside AAD B2C?

Setting a default value on a "ReadOnly" DisplayClaim gets the value out to the page:

      <ClaimType Id="myClaim">
        <DisplayName>DEBUG: Never display this</DisplayName>        
        <DataType>string</DataType>
        <UserInputType>Readonly</UserInputType>
      </ClaimType>

but then you have to goto extra lengths to hide it that may become fragile if the B2C HTML DOM output format ever changes:

var myClaim = document.getElementById("myClaim"); //too bad this cant just be a hidden field
var myClaimValue = myClaim.value; 
myClaim.parentElement.parentElement.style.display = "none"; //hide parent div's parent li
felickz
  • 4,292
  • 3
  • 33
  • 37
  • Not out of the box, but it would be an interesting feature that I would vote for! – Brad C. Mar 04 '21 at 16:00
  • @BradC. i will take your comment to heart, one moment :) – felickz Mar 04 '21 at 16:01
  • @BradC. - upvotes :) https://feedback.azure.com/forums/169401-azure-active-directory/suggestions/42831765-b2c-custom-content-add-hiddenfield-as-userinputt – felickz Mar 04 '21 at 16:04
  • Great job - I've submitted my upvote! – Brad C. Mar 04 '21 at 16:13
  • If you explicitely use content version then the DOM should not change. Every custom UI template relies on DOM looking in a specific way. See docs: https://learn.microsoft.com/en-us/azure/active-directory-b2c/contentdefinitions#select-a-page-layout – wojtekdo Mar 04 '21 at 16:38
  • @wojtekdo - good point, but it sill makes my client side code fragile to future template updates, whereas if there was a hidden field control i wouldnt need to write that code. – felickz Mar 05 '21 at 05:41

1 Answers1

2

As commented on initial question, this is not supported currently.

If you ended up on this post, please upvote this feature request: https://feedback.azure.com/d365community/idea/5f39dfe1-b625-ec11-b6e6-000d3a4f0789

felickz
  • 4,292
  • 3
  • 33
  • 37