Adding values to a multi-select field with deluge

Adding values to a multi-select field with deluge

Because subforms will only create new rows, I'm using deluge to recall information from a form into the subrows to mimic the behaviour of updating a row rather than creating it.

I have a multi select field called "locations" that is a list of locations for the client, and for every one they choose the subrow is populated with the existing data about that location from a form called "location" (confusing I know). When the form is saved it pushes any updates to that original form and all is well.

When the client edits the form I need a way to rebuild that subform data and the choices in the multi select. However I'm having trouble pushing the results to the multiselect field.

I hope this helps :

  1. // Get all the choices that were made for this record
  2. varFetchChoices = benchmarks [ ID == input.ID ].locations.getAll();
  3. //Clear existing subrows and choices
  4. clear locations;
  5. input.SUB_LOCATIONS.clear();
  6. //Rebuild the multiselect by looking up each location
  7. varFetch =benchmarks [ ID == input.ID ].locations.getAll();
  8.  for each  varRow in varFetch
  9. {
  10.    input.locations = varRow;
  11. }

When I set up an alert on varRow, it displays the ID of each of the locations separately as I would expect, but it only ever inputs the one location.

I suspect it's because I need to add the varRow to a list and then insert that into the multi select - but I can't get the phrasing quite right



This is what I need the end result to look like (with varying numbers of sites)



And this is the code I am using to bring the data into the subform when a multiselect choice is made

  1. //Count Subform Rows
  2. varRowCount = 0;
  3. for each  row in SUB_LOCATIONS
  4. {
  5.     if(row.ID != 0)
  6.     {
  7.         varRowCount = varRowCount + 1;
  8.     }
  9. }
  10. // Collect all the locations that are associated with this client and add to a collection
  11. if(location[ID = input.locations].ID != null)
  12. {
  13.     //create and clear the list
  14.     varCollection = Collection();
  15.     varCollection.clear();
  16.     //Add locations to the collection
  17.     varCollection.insertall(input.locations);
  18.     //Get the size of the collection (minus a one because it's a zero index)
  19.     varLocationCount = varCollection.size() - 1;
  20.     //Returns the ID of the last in the list
  21.     varLastLocation = varCollection.get(varLocationCount);
  22.     //Fetch the location about the chosen location
  23.     varFetchLocation = location[ID == varLastLocation];
  24.     //
  25.     // Now let's populate the subform
  26.     for each  varLocation in varFetchLocation
  27.     {
  28.         //create the "varNewRow" variable for holding the new row data
  29.         varNewRow = Build_your_benchmark.SUB_LOCATIONS();
  30.        //
  31.        //Set the values for each row to the varNewRow variable
  32.         varNewRow.location_name=varFetchLocation.location_name;
  33.         varNewRow.benchmark_sector=varFetchLocation.benchmark_sector;
  34.         varNewRow.region=varFetchLocation.region;
  35.         varNewRow.occupants=varFetchLocation.occupants;
  36.         varNewRow.floor_area=varFetchLocation.floor_area;
  37.         // 
  38.         //Insert "varNewRow" to new row on the subform   
  39.         input.SUB_LOCATIONS.insert(varNewRow);
  40.     }
  41. }

I hope that makes sense
    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

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

                            Zoho CRM コンテンツ




                              ご検討中の方