Set Criteria in Deluge Scripting not holding when edit Form

Set Criteria in Deluge Scripting not holding when edit Form

I have the below deluge scripting for a field in "Actions on User Input," so that I can populate fields (e.g. Color_Courses) with data from another table.   However, the problem is that when I want to edit the form at a later time, none of these criteria stay in place.  What do I need to do?  Thanks for the help. 

if (count(Courses[LP == input.LP])  ==  0)
{
    clear Color_Courses;
}
else
{
    itemlist  =  Courses  [LP == input.LP] sort by  LP ;
    Color_Courses:ui.add(itemlist.Course_Name.getall());
}
if (count(Courses[LP == input.LP])  ==  0)
{
    clear Flip_Courses;
}
else
{
    itemlist3  =  Courses  [LP == input.LP] sort by  LP ;
    Flip_Courses:ui.add(itemlist3.Course_Name.getall());
}