Unfortunately you cannot do a lookup on anything that is not a DataView or Data Extension via AMPScript.
To that extent, when working in AMPScript - you are left with 2 options:
- Adding a second Simple Filter Part (SFP), creating a complex filter. This SFP would utilize the operator 'IN' to segment the results to just the group of lists you want to look up.
e.g.
/* Create LeftOperand SimpleFilterPart */
Set @sfp1 = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp, "Property", "SubscriberKey")
SetObjectProperty(@sfp, "SimpleOperator", "equals")
AddObjectArrayItem(@sfp, "Value", @subkey)
/* Create RightOperand SimpleFilterPart */
Set @sfp2 = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp, "Property", "ListID")
SetObjectProperty(@sfp, "SimpleOperator", "IN")
AddObjectArrayItem(@sfp, "Value", @ListIDs)
/* Adding two Simple filters together to create a Complex filter */
Set @cf1 = CreateObject("ComplexFilterPart")
SetObjectProperty(@cf1,"LeftOperand",@sfp1)
SetObjectProperty(@cf1,"RightOperand",@sfp2)
SetObjectProperty(@cf1,"LogicalOperator","AND")
SetObjectProperty(@rr,"Filter",@cf1)
- If you cannot use the filter from above, you will need to do your for loop with a conditional in it to make sure to only pull/record entries that fit your criteria.
e.g.
set @listStatuses = InvokeRetrieve(@rr, @rrStatus, @rrRequestID)
FOR @i=1 TO Rowcount(@listStatuses) DO
SET @row = ROW(@listStatuses, @i)
SET @SubscriberKey = Field(@row, "SubscriberKey")
SET @ListID = Field(@row, "ListID")
SET @Status = Field(@row, "Status")
IF @ListID == @ListID1 THEN
SET @doAction = 1
ELSEIF @ListID == @ListID2 THEN
SET @doAction = 1
ELSEIF @ListID == @ListID3 THEN
SET @doAction = 1
/* Etc.... */
ELSE
SET @doAction = 0
ENDIF
IF @doAction = 1 THEN
/* Action you wish to do */
ENDIF
NEXT @i
If your List IDs are saved inside of another rowset, you can also have a for loop inside of your for loop to loop through and verify via conditionals again. I do not recommend this unless you do not expect high volume as this will be a large draw on resources and cause high run times (potentially causing a time-out).
(Assuming this is a non-sending environment) I would also recommend looking into using WSProxy for your API calls instead of the AMPScript method.
This will lead you into using SSJS (SFMC version) which can provide more flexibility on interaction as it will be returned in a JSON object. Feel free to look up basic JavaScript methods to pull only specific values from Arrays/Objects.