# Finding Ticket ID

**URL:** <https://community.hubspot.com/t/finding-ticket-id/122773>\
**Category:** APIs & Integrations\
**Tags:** workflows\
**Created:** [December 18, 2024, 9:50pm UTC](https://community.hubspot.com/t/finding-ticket-id/122773 "2024-12-18T21:50:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DHills48](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@DHills48](https://community.hubspot.com/u/DHills48)\
**Post date:** [December 18, 2024, 9:50pm UTC](https://community.hubspot.com/t/finding-ticket-id/122773/1 "2024-12-18T21:50:51Z")

</div>

Hello,

I’m trying to rename tickets in my HubSpot portal. The tickets that a created by integration are labeled “case created” and there are hundreds of them.

To fix it, I’m working on code in a Custom Workflow step to grab the text between two strings (“subject:” and “priority”) and put it in as the new ticket name.  
Here’s a link to my code.

> <https://github.com/MicroStomatid/HubSpotHelp/blob/main/UpdatingTicketNames>

The error I get is:

`Unhandled Promise Rejection`

Thank you!

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [December 18, 2024, 10:50pm UTC](https://community.hubspot.com/t/finding-ticket-id/122773/2 "2024-12-18T22:50:49Z")

</div>

Hi @DHills48 👋

I think it may just be related to a typo in your code -- “inputfields” instead of “inputFields”. Regardless, here’s a simplified version of your example using HubSpot’s Node.Js client library (rather than axios).

```lia-code-sample
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ "accessToken": process.env.your_hs_pat_secret_name });

exports.main = async (event, callback) => {
 const content = event.inputFields['content']; // assumes this is a ticket-based workflow and ticket 'content' has been configured as a custom code 'property to include'
 const matched = content.match(/Subject:\s*(.*?)\s*Priority:/);
 const subject = matched ? matched[1] : "Not Found";
 const ticketId = event.inputFields['hs_object_id']; // assumes this is a ticket-based workflow and ticket 'hs_object_id' has been configured as a custom code 'property to include'
 const properties = {
 "subject": subject
 };
 const SimplePublicObjectInput = { properties };

 // update ticket
 try {
 const apiResponse = await hubspotClient.crm.tickets.basicApi.update(ticketId, SimplePublicObjectInput);
 console.log(JSON.stringify(apiResponse, null, 2));
 } catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
 }

 callback({
 outputFields: {
 matched: matched,
 subject: subject
 }
 });
}

```

I hope that proves helpful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![DHills48](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@DHills48](https://community.hubspot.com/u/DHills48)\
**Post date:** [December 23, 2024, 8:34pm UTC](https://community.hubspot.com/t/finding-ticket-id/122773/3 "2024-12-23T20:34:34Z")

</div>

Hi Zach,  
Thank you for feedback. You’re right, I did have a typo. I updated it to “inputFields” then it worked - though I ran into different errors.  
I tried your code and it gave me this error (and I believe I updated the code your provided correctly):

`ERROR	RequiredError: Required parameter ticketId was null or undefined when calling BasicApi.update.`

---

<div class="post-metadata">

**Author:** ![DHills48](https://avatars.discourse-cdn.com/v4/letter/d/35a633/32.png) [@DHills48](https://community.hubspot.com/u/DHills48)\
**Post date:** [December 23, 2024, 10:31pm UTC](https://community.hubspot.com/t/finding-ticket-id/122773/4 "2024-12-23T22:31:15Z")

</div>

Nevermind, I fixed the error. I just has to update the Ticket ID line.  
Thank you, very much!
