2021 Apr 16 11:15 AM
There is an array :
Array: this.getView().getModel("objects").getProperty("/developmentObjects")
I want to find the index in the array, but there are two parameters that should be equal:
Array.findIndex( developmentObject => (developmentObject.microserviceId == microserviceId && developmentObject.objectName == objectName));
The microserviceId and the objectName should bot fulfill the value.
From my coding, the return value is -1.
But this development object is really in the table
How can I change the sentence?
2021 Apr 16 11:57 AM
Dear Bella,
Maybe you can check this page for an working example.
This tutorial might help too.
I also would debug the code or use the console to find the values being evaluated by findIndex and see why the result is -1.
Kind regards,
Cris
2021 Apr 16 11:57 AM
Dear Bella,
Maybe you can check this page for an working example.
This tutorial might help too.
I also would debug the code or use the console to find the values being evaluated by findIndex and see why the result is -1.
Kind regards,
Cris
2021 Apr 19 7:05 AM
Dear cristiano.hansenn
Thanks for your reply, I checked the page, but all the example provide only one parameter.
It is ok for my example if I only set one parameter:
Array.findIndex( developmentObject => developmentObject.uuid == uuid );
But when I change it to fulfill two conditions, then the result will be -1 for my example:
Array.findIndex( developmentObject => (developmentObject.microserviceId == microserviceId && developmentObject.objectName == objectName));
I can find the object in the array, but the findindex result is -1, I think maybe I have some syntax error.
2021 Apr 19 4:19 PM
Dear Bella,
Have you tried:
Array.findIndex( developmentObject => ((developmentObject.microserviceId == microserviceId) && (developmentObject.objectName == objectName)));
?
Maybe you can print the values, just to be sure that the values are the expected ones.
I'll see whether I find an example with two conditions.
Regards,
Cris
2021 Apr 26 7:27 AM
Dear cristiano.hansenn,
I found my function is correct, there is only incorrect objectName in my functtion,
Array.findIndex( developmentObject => (developmentObject.microserviceId == microserviceId && developmentObject.objectName == objectName));
Thanks
2021 Apr 22 1:46 PM
Hi bella.fang,
Could you please share example data of your model (without sensitive information)?
Especially the developmentObjects part.
The syntax you are using is correct: Arrow function expressions - JavaScript | MDN
Regards,
Peter