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;