cancel
Showing results for 
Search instead for 
Did you mean: 

Get logged in user data in SAP Work Zone

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?

Accepted Solutions (0)

Answers (3)

Answers (3)

stippi
Employee
Employee

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.

muzammo
Explorer
0 Kudos

In any controller Init function you can call below code : 

 

this.getOwnerComponent().oComponentData._sapUiIntegration_card.getHostInstance().getContextValue("sap.workzone/currentUser/email").then(function(value){console.log(value)})

apologies for any typo. 

muzammo
Explorer
0 Kudos
  •