Update Test field using PATCH web service

I know I can update a single field using a PATCH call and use the operator "Replace". Is there a way to append text onto the end of existing text in a text field?

I have a workflow with several web services that are making child tickets under a Problem ticket. I want to record in the problem ticket that a Child ticket was completed successfully. I was planning on making the success leg of the workflow go to another web service that does the update on the Problem ticket. I want to do this several times and want to record each successful ticket creation.

I found that Rest API Patch method can use the "Add" operator to update an existing array of values. I want to do the same but on a text field.

I also know the workflow steps are in the history and ticket feed, but I'd like for all the child ticket success statuses to be in a concise format in the ticket for easy manual review by technicians.

Asked by Nathaniel Obee on Tue 3/29/22 4:41 PM
Sign In to leave feedback or contribute an answer

Answer (1)

This answer has been marked as the accepted answer
Mark Sayers Tue 3/29/22 4:45 PM

Hello Nathaniel,

If it's a text type attribute, you should be able to define that attribute as a parameter, then when you are constructing the PATCH call's body, refer to the attribute parameter first in the value property, then supply whatever you are wanting to append to it after that, still within the value property.

You'd still continue to use the "replace" operator though as you are replacing the old value with a new value.

No feedback
Hi Mark,
Love the super quick response!
I don't want to replace, I want to append to the existing text in the field. I want to add six different responses each from its own web service call into the same field and see all six messages.

Nate
- Nathaniel Obee Tue 3/29/22 4:48 PM
Right. In this scenario the result of using an Add vs a Replace operator will be the same. The Add operator is technically to be used when you need to "add" that attribute to the ticket because it isn't currently on the ticket's form.

Either way, formatting the PATCH call with the parameter and then referencing that in the body when you go to generate the new value for the attribute is the right way to go.
- Mark Sayers Tue 3/29/22 4:55 PM
The add operator also overwrites whatever was in the text field. From what I understand it's intended to be used to add a value at specific array index. I guess if its a text field instead of the array it just replaces.
I suppose I could use another web service to read the ticket data to get the existing text, parse that into a parameter and then append the new message to that parameter in my PATCH Body. So the existing data is in the new update call, making the replace viable.

That's a lot of steps.
Side note, is it normal for each web service step in a workflow to take five minutes? Testing from the Web service config screen returns in a few seconds. But when chained up in a workflow they each take 5 minutes every time.
- Nathaniel Obee Tue 3/29/22 5:09 PM
Yes, in a workflow the processor that handles currently-active web service workflow steps runs on a 5 minute interval. This is baked into the system and isn't configurable currently. - Mark Sayers Wed 3/30/22 9:13 AM