Mass Action Button Script

Mass Action Button Script

Hi all,

I've been trying to search a lot of places for a solution on how to do a button placed at the "Mass Action Menu" and thus only updating multiple CHOSEN records at once. After finding no success whatsoever, I decided to just run and test whatever I can think of and finally, it worked; thanks to no easily accessible resources by Zoho ( you guys really need to improve this).

Right, to the function.

In the function you are about to write, you can edit the Arguments. Let's say for example we're dealing with the Deals module, then what you want to do is add an argument mapping to the Deal ID field. I would suggest putting the mapping value as a plural (i.e: DealIDs) because we will be dealing with multiple records most of the time.

Now, what would happen when the button is clicked when multiple records are chosen is, it would return the IDs of the Deals record like this:

1243331222221004|||1243331222221005|||1243331222221006

Why? Hell, I have no idea. But this is a string value. We have to convert this string into a list and that's simple. Simply write this line:
  1. if(DealIDs.contains("|||") == true)
    {
  2. DealIDs = DealIDs.toList("|||");
  3. }
  4. else
  5. {
  6. DealIDs = DealIDs.toList();
  7. }
This will change the string value to a list. And why do I do the conditional thing is because there is a possibility that only one record is chosen and in that case, there will be no "|||" in the returned value.

Then, simply do the "for each" thing, for example;
  1. for each DealID in DealIDs
  2. {
  3. updateStage = Map();
  4. updateStage.put("Stage","Closed_Won");
  5. updateDeal = zoho.crm.updateRecord("Deals",DealID,updateStage);
  6. }
  7. return "The deals are updated successfully";
And it should work just fine. Hope this helps. And hey, if you have a better way, please please please tell me, I'm not a programmer so my work might not be optimal.

Cheers!

      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          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 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 コンテンツ



                                ご検討中の方