Script Troubleshooting help

Script Troubleshooting help

I have form called “Add a Student” with a multiselect field called “Enrolled Classes”.

I have another form called “Classes” with a field called "Max number of students” and a field called "Number of Students Enrolled” which counts how many students are listed as enrolled in that class.

When I load my “Add a Student" form I only want to be able to select Classes that have spots available in them. Ie: "Max number of students” < "Number of Students Enrolled”. I have a workflow to do this:

classesAvailableList = Add_a_Class[Number_of_Students_Enrolled < Max_number_of_students].ID.getAll();

However the issue I am having is that if I select a student to edit, any classes that where previously selected are deselected. - 

Any ideas how I could fix this?

          Zoho TeamInbox Resources

            Zoho DataPrep Resources

                Zoho CRM Plus Resources

                  Zoho Books Resources

                    Zoho Subscriptions Resources

                      Zoho Desk Resources

                        Zoho Projects Resources

                          Zoho Sprints Resources

                            Zoho Orchestly Resources

                              Zoho Creator Resources

                                Zoho WorkDrive Resources

                                    Zoho Campaigns Resources

                                      Zoho CRM Resources

                                                    Design. Discuss. Deliver.

                                                    Create visually engaging stories with Zoho Show.

                                                    Get Started Now

                                                      Zoho Show Resources

                                                        Zoho Writer Writer

                                                        Get Started. Write Away!

                                                        Writer is a powerful online word processor, designed for collaborative work.