Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Setting a JSON Model value in a JavaScript Variable

Hi fórum

I have a SAP UI5 XML View that show the value of a Json Model .... in a Text Component

<Text xmlns="sap.m" id="iduser" text="{userapi>/displayName}"></text>

That´s work fine, but I want to setting the value of {userapi>/displayName} in a JavaScript Variable... how can i do that ?


In the "index.html" i have the next code... and in this part i need the JavaScript Variable with the value of "displayname".

var userModel = new sap.ui.model.json.JSONMODEL("/services/userapi/currentUser");

sap.ui.getCore.setModel(userModel, "userapi");

Thanks

Former Member
Former Member replied

hi Josue,

     Try


     var sDisplayName = sap.ui.getCore.getModel("userapi").getData().displayName;

Regards

Aasif Shah

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question