Accessing list items of global variable as input in the test script

I have saved a global variable as a list with different values.

image

I want to use these values in my test script. Like, there is a search bar, and first it should input the first value and then in the same test script, it should enter the second value in the same search bar.

I have worked with data binding before but that was to run the same test with different input values. So the test would run completely with one value and then trigger a new test automatically and run with the second value. But in this scenario, it should take multiple values from the global variable list.

Is there a way to do something like this:

WebUI.sendKeys(findTestObject('Search bar object'), GlobalVariable.ItemIDs(pick first element here)
// do some stuff 

WebUI.sendKeys(findTestObject('Search bar object'), GlobalVariable.ItemIDs(pick second element here)
WebUI.sendKeys(findTestObject('Search bar object'),
    GlobalVariable.ItemIDs[0])

WebUI.sendKeys(findTestObject('Search bar object'),
    GlobalVariable.ItemIDs[1])