Hi
One of the field in presentation layer as part of 'predefined answers' property makes a call to the action script that internally returns a array containing key and value pair
{
"name1":"instanceid1",
"name2":"instanceid2"
}
What I want to display to the user as part of field input are the keys i.e. name1, name2 only and when the user select the key, internally I want to fetch the correspond value (which in this case instanceid1 or instanceid2) in order to talk to the endpoint i.e. rest server.
Please let me know how to do this in vRO.
Thanks in advance,
Salil
http://manvsvcac.com/Articles/Lab_Resources_Round03.html
is a great example of how to access ResourceElements. Hope that helps.
if the action return is the contents of the presentation then you need to change the return of the action to the values that you want to return.
Loop through the array that is returns now and push the keys to a new array and return that one;
var newAry = [];
for(var i in oldAry)
{
newAry.push(i.key);
}
r
eturn newAry;
Thanks for your response!!
In my case keys are what I want to display to the user and based on the key selection the correspond value i.e. instanceid is what I want to use to communicate to the REST endpoint.
The solution that you proposed, will result into display of the keys but I will loose the metadata i.e. correspond value which is needed, to talk to the server endpoint.
Thanks and Regards,
Salil
You could use a resource to build the key-pair relationship. Display the keys to the user, then query the resource object using the key as a parameter.
Appreciate your reply!
>>You could use a resource to build the key-pair relationship
By using resource you mean ResourceElement type in vRO? If possible, can you please give me an example?
http://manvsvcac.com/Articles/Lab_Resources_Round03.html
is a great example of how to access ResourceElements. Hope that helps.
Yes this helped. Thank you so much!!