cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically setting a value in array SAPUI5

meenakshi_raina
Advisor
Advisor
0 Kudos

Hi All,

I am trying to set some data in one of the arrays using the index. If I pass the index value directly (example 0), then the data is set correctly. While if I pass the index value dynamically, as shown below, the data is not set.

In the below 2 examples, the 1st one works correctly, while the 2nd one returns "undefined"-

1. this.getView().getModel("detailView").setProperty("/PermitHdrSet/to_locklinkup/0/LockoutDetSet", tabItems);
2. this.getView().getModel("detailView").setProperty("/PermitHdrSet/to_locklinkup/n/LockoutDetSet", tabItems);

Accepted Solutions (1)

Accepted Solutions (1)

david_bizer
Product and Topic Expert
Product and Topic Expert

Hi,

where do you iterate to dynamically set the value n?

you could construct your property string , e.g. "/PermitHdrSet/to_locklinkup/" + n +"/LockoutDetSet" or make use of a template string `/PermitHdrSet/to_locklinkup/${n}/LockoutDetSet`

Best regards

meenakshi_raina
Advisor
Advisor
0 Kudos

Thanks David. It worked.

Answers (0)