How to use select row option in random documents?

Hi folks

I’m getting invoice randomly.But line item is keep on changing the count i.e 2 line-1st invoice,3 line-2nd invoice .So,in the case how to handle dynamically?
image