openID variable name instead of missing value from JSON

Hi,

when value in userinfo JSON response is NULL then in xwiki instead of NULL or empty string, variable name apperar.
Example: if mobilePhone is NULL in JSON, then Phone will be ${oidc.user.mobilePhone._clean}

How to change it to empty string if value is NULL?

image

in JSON:
image

See more details regarding the syntax on https://commons.apache.org/proper/commons-text/apidocs/org/apache/commons/text/StringSubstitutor.html (just added the link to the documentation, thanks for the reminder).

From what I understand It’s possible to provide a default value. In your case I think it should be something like

${oidc.user.mobilePhone._clean:-}

I changed all to:

oidc.user.mapping=birthday=${oidc.user.birthday:-}
oidc.user.mapping=mySite=${oidc.user.mySite:-}
oidc.user.mapping=city=${oidc.user.city:-}
oidc.user.mapping=companyName=${oidc.user.companyName:-}
oidc.user.mapping=country=${oidc.user.country:-}
oidc.user.mapping=department=${oidc.user.department:-}
oidc.user.mapping=displayName=${oidc.user.displayName:-}
oidc.user.mapping=givenName=${oidc.user.givenName:-}
oidc.user.mapping=first_name=${oidc.user.givenName:-}
oidc.user.mapping=id=${oidc.user.id:-}
oidc.user.mapping=mailNickname=${oidc.user.mailNickname:-}
oidc.user.mapping=mobilePhone=${oidc.user.mobilePhone:-}
oidc.user.mapping=officeLocation=${oidc.user.officeLocation:-}
oidc.user.mapping=postalCode=${oidc.user.postalCode:-}
oidc.user.mapping=streetAddress=${oidc.user.streetAddress:-}
oidc.user.mapping=surname=${oidc.user.surname:-}
oidc.user.mapping=name=${oidc.user.givenName:-} ${oidc.user.surname:-} (${oidc.user.mailNickname:-})
oidc.user.mapping=last_name=${oidc.user.surname:-}
oidc.user.mapping=jobTitle=${oidc.user.jobTitle:-}
oidc.user.mapping=mail=${oidc.user.mail:-}
oidc.user.mapping=workAddress=${oidc.user.streetAddress:-}\n${oidc.user.city:-}\n${oidc.user.postalCode:-}\n${oidc.user.country:-}

But now I get everything empyt :frowning:

OK, I fixed it by velocity. I added this code to all my fields in Custom Display :slight_smile:

{{velocity}}
#if($value.toString().contains("oidc.user."))
  -
#else
  $value
#end
{{/velocity}}

but it add <p>

image