Best of Support

Deleting sub-Dialog collections with code

Issue

I have a sub-Dialog collection and, based on a check box value, would like to either add or delete an item from the collection. I have the code for adding it…what is the code for removing it?

Solution

The following will delete all items in a dialog collection (in this example called "sub"):

 

%[RepeatBlockWhile(ThisDialog.sub.count>0)]
    %[
ThisDialog.Sub.delete(1)]
%[
EndBlock]

 

The following will delete a specific collection item based on its name:

 

%[i=1]
%[
RepeatBlockWhile(i<=ThisDialog.sub.count)]
    %[
KeepBlockIf(ThisDialog.sub[i]._name = "ABC")]
        %[
ThisDialog.Sub.delete(i)]
        %[
i=i-1]
    %[
EndBlock]
%[
i=i+1]
%[
EndBlock]

 

Dan Todes