Using additional and custom attributes with JS
To access additional and custom attributes in JS, the JS method getAdditionalAttributes()
is provided. To use the method in a CustomLayout
or CustomProductPage
, call this.getAdditionalAttributes()
to retrieve both additional and custom attributes.
Example
The mTAN authentication step page (path: '/auth/flow/{{FLOW}}/mtan'
) returns an additional attribute {"resendPossible": true}
and has a custom attribute configured with {customAttributes.myKey: "my value"}
. See below for an example JSON structure:
{ "nextAuthStep": "MTAN_OTP_REQUIRED", "phoneNumber": "+41789071171", "resendPossible": true, "customAttributes": { "myKey": "my value" } }
In this situation, the following JS methods can be used:
this.getAdditionalAttributes()
Will return all additional and all custom attributesthis.getAdditionalAttributes().get("customAttributes")
Will return all custom attributesthis.getAdditionalAttributes().get("resendPossible")
Will returntrue
this.getAdditionalAttributes().get("customAttributes").myKey
Will return"my value"