Custom Function to Update Ticket based on Subject of Ticket

Custom Function to Update Ticket based on Subject of Ticket

This may be pretty simple but I'm having issues with getting a custom function to fill out custom fields based on the subject of a ticket and not the body of a ticket.  Basically we need to fill in the PO number and Item ID custom fields, both of this information is automatically added into the subject of the ticket not the body of the ticket. Below is the custom function, which is working to pull information from the body of the ticket (when manually moving the PO number and Item ID to the body of the ticket) : 


orgId = "XXXXX";
pofromWord = "PO";
potoWord = ";";
itemIDfromWord = "Item:";
itemIDtoWord = "QTYOpen:";
lenpofromWord = pofromWord.length();
lenitemIDfromWord = itemIDfromWord.length();
T_Info = invokeurl
[
url :"https://desk.zoho.com/api/v1/tickets/" + TicketID + "/latestThread?include=plainText"
type :GET
connection:"zohodesk"
];
plainText = T_Info.getJSON("plainText");
po = plainText.subText(plainText.indexOf(pofromWord) + lenpofromWord,plainText.indexOf(potoWord));
itemID = plainText.subText(plainText.indexOf(itemIDfromWord) + lenitemIDfromWord,plainText.indexOf(itemIDtoWord));
updateTicket = zoho.desk.update(orgId,"tickets",TicketID,{"cf":{"cf_vendor_po":po}});
updateTicket = zoho.desk.update(orgId,"tickets",TicketID,{"cf":{"cf_item_id":itemID}});
info updateTicket;


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






                                ご検討中の方