Add new string to a list with custom function

Add new string to a list with custom function

Hi friends,

I'm trying to insert data from a Zoho CRM text field into a multi-select field also in Zoho CRM using Zoho Flow.

After spending a couple hours trying to build a proper function with no success, I'm here to ask for some help. :)

Basically, I need to get a text from the field A (text type) and add it the field B, however, B is a multi-select field type and the text from A should be added to B while keeping the previous data.

Example:
1. Field A has the string "soccer"
2. Field B has the list "john", "mary", "peter"

The expected result is:
3. Now Field B has the data: "soccer", "john", "mary", "peter"

Could you help me to fix this custom function to use it in Zoho Flow?

Thank you!

More information below:

The actual script is only returning "soccer", disregarding all source values from the multi-select field (B).


Custom function script: https://zwdrive.com/juGb57
Custom function input: https://zwdrive.com/sj2jzO
Custom function output: https://zwdrive.com/b9RIIA
Custom function script below:
  1. list addToList(list TopicsList, string newTopic)
    {
    if(newTopic == null)
    {
        return list();
    }
    TopicsList = input.newTopic.tolist(";");
    return TopicsList;
    }





                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation


                                        Manage your brands on social media



                                                Zoho TeamInbox Resources

                                                  Zoho DataPrep Resources



                                                    Zoho CRM Plus Resources

                                                      Zoho Books Resources


                                                        Zoho Subscriptions Resources

                                                          Zoho Projects Resources


                                                            Zoho Sprints Resources


                                                              Qntrl 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




                                                                            Design. Discuss. Deliver.

                                                                            Create visually engaging stories with Zoho Show.

                                                                            Get Started Now