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;

    Access your files securely from anywhere

        Zoho Developer Community




                                  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 Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • 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