I am creating a publication centre using which a user can opt-in for a list. For this purpose, I have to initially check if the subscriber already exists in a list or not. I am using the following code to check whether he is a part of the list or not.
%%[
var @rr1, @sfp4, @sfp5, @cf0, @LookUpSub, @RowCountSub
SET @rr1 = CreateObject("RetrieveRequest")
SetObjectProperty(@rr1, "ObjectType", "ListSubscriber")
AddObjectArrayItem(@rr1,"Properties","ListID")
AddObjectArrayItem(@rr1,"Properties","SubscriberKey")
SET @sfp4 = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp4, "Property", "SubscriberKey")
SetObjectProperty(@sfp4, "SimpleOperator", "equals")
AddObjectArrayItem(@sfp4, "Value",@sub_ID)
SET @sfp5 = CreateObject("SimpleFilterPart")
SetObjectProperty(@sfp5, "Property", "ListID")
SetObjectProperty(@sfp5, "SimpleOperator", "equals")
AddObjectArrayItem(@sfp5, "Value",@lis_ID)
Set @cf0 = CreateObject("ComplexFilterPart")
SetObjectProperty(@cf0,"LeftOperand",@sfp4)
SetObjectProperty(@cf0,"RightOperand",@sfp5)
SetObjectProperty(@cf0,"LogicalOperator","AND")
SetObjectProperty(@rr1, "Filter", @cf0)
SET @LookUpSub = InvokeRetrieve(@rr1)
SET @RowCountSub = Rowcount(@LookUpSub)
]%%
This is inside a for loop checking for every list. But when I run this I get an error.
ExactTarget.OMM.InvalidScriptException: The function expression is invalid. See inner exception for detail.
Script: ContentBlockByName(@contentAreaPath)\r\n Index: 4342\r\n ListID: 0\r\n Error Code: OMM_FUNC_EXPR_INVALID
- from Jint -->
--- inner exception 1---
ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a ContentBlockByName function call.
Function Call: ContentBlockByName(@contentAreaPath)
See inner exception for details.
Error Code: OMM_FUNC_EXEC_ERROR
- from OMMCommon -->
--- inner exception 2---
ExactTarget.OMM.InvalidScriptException: The function expression is invalid. See inner exception for detail.
Script: AddObjectArrayItem(@sfp5, \"Value\",@lis_ID)
Index: 839
ListID: 0
Error Code: OMM_FUNC_EXPR_INVALID
- from OMMCommon -->
--- inner exception 3---
nExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a AddObjectArrayItem function call. See inner exception for details.
Error Code: OMM_FUNC_EXEC_ERROR
- from OMMCommon -->
--- inner exception 4---
System.InvalidCastException: Object cannot be stored in an array of this type. - from mscorlib
This is because I am guessing I cannot reuse the same variable names for different search purposes. I looked around and I found that declaring variables like var @xyz can empty or flush the previously existing values but it's not working here. Is there a work around this issue or something that can resolve the problem? Thank you for your help.