cancel
Showing results for 
Search instead for 
Did you mean: 

Get logged in user data in SAP Work Zone

2,137

Hi I am currently working on a Card in SAP Work Zone that should display the current logged in user. Is there a way to get the logged in user data from SAP Work Zone and add it in the Card?

View Entire Topic
stippi
Advisor
Advisor

Yes. If you have the card instance, you can call getHostInstance() on it to obtain context information in Work Zone:

card.getHostInstance().getContextValue("sap.workzone/currentUser")

Note that this returns a Promise. See https://help.sap.com/docs/WZ/7d3b9c7211ca4d7a9630b524205ee836/e69aef3fb6f448d084ce601ebf4555da.html?... for more information. Also the documentation for getContextValue(): https://ui5.sap.com/#/api/sap.ui.integration.Host%23methods/getContextValue

JBrook
Explorer
0 Kudos

Where do you call this function? In the configuration.js?

JBrook
Explorer
0 Kudos

There's just the /dt/configuration.js file..

Designtime configuration file.

sladerose
Explorer
0 Kudos
Hi Stippi, could you explain how I do this in a UI integration card deployed on Build Work Zone?
AlessioF
Discoverer
0 Kudos

Hi , I am trying to get the user logged , but my card instance doesn't have the method getHostInstance(). I am trying to find it in the extension.js , do you have to call it in the configuration.js? If yes could you send a snippet to see how it should look like? Thank you .

muzammo
Explorer
0 Kudos
You can use this in component card, where you can place this code in on Init function of controller