Skip to main content
Question

Workflow action based on api results (GET+PUT)


Forum|alt.badge.img+6

Hi,

I setup a huge employee onboarding workflow base on employee office city.

I want to be able to change the department of a ticket base on the “department” field in the form.
HR will use the form and indicate the employee Department using a dropdown base on the department  section of freshservice.
I want to use the API to GET the ticket detail including department id:
https://example.freshservice.com/api/v2/tickets/8361
It works perfectly.

After that, I copy the JSON, put it inside JSON analyser app, but when I try generate the output, I see this:
 

My guess is because the field is a text one, but FreshService use a number: 19000261110

Is it possible to convert this value receive from text to a number without using condition, becacuse I will need to clone too many things which will take me a lot of hours of time to clone everything 6 times for our 6 departements for each branch in the workflow which mean more than 200 things to clone at the end because there is no copy+paste option in workflow.. (

 

 

 

Thank you and sorry for my english.

Did this topic help you find an answer to your question?

3 replies

zebb.s
Contributor
Forum|alt.badge.img+2
  • Contributor
  • 21 replies
  • August 11, 2022

Hi.  Is the department free text?  We use departments imported from AD, so I believe we’d need to use a placeholder.  Something like {{ticket.ri_72_cf_department}} (specific to this service request).  When I get a return on it, it shows as:

"department_id_value": 17000222729

I would suggest reaching out to support@freshservice.com as I’ve had luck with them helping me with API issues. 


zachary.king
Skilled Expert
Forum|alt.badge.img+16
  • Skilled Expert
  • 951 replies
  • August 12, 2022

Hello @maxlehot1234 if you are using a service request you should be able to access the “Departement ID” dropdown field using a placeholder as @zebb.s mentioned. From there you can use that field in a “Trigger Webhook” action node that updates the ticket. If you are getting a data type error, try using the expression block on the placeholder to change the type to number. You might even be able to do that with the Liquid Language. I found this by searching how to convert a string to an integer in liquid

To convert a string to a number just add 0 to the variable:

1

{% assign number = number | plus:0 %}

 

Might be worth a try. Hope that helps!


Forum|alt.badge.img+6
  • Author
  • Skilled Expert
  • 39 replies
  • August 12, 2022
zebb.s wrote:

Hi.  Is the department free text?  We use departments imported from AD, so I believe we’d need to use a placeholder.  Something like {{ticket.ri_72_cf_department}} (specific to this service request).  When I get a return on it, it shows as:

"department_id_value": 17000222729

I would suggest reaching out to support@freshservice.com as I’ve had luck with them helping me with API issues. 

Hi,

The departement is a dropdown list. All Departements ( 6 exactly) are sync from our local Active Directory server.
 

 

 

 

zachary.king wrote:

Hello @maxlehot1234 if you are using a service request you should be able to access the “Departement ID” dropdown field using a placeholder as @zebb.s mentioned. From there you can use that field in a “Trigger Webhook” action node that updates the ticket. If you are getting a data type error, try using the expression block on the placeholder to change the type to number. You might even be able to do that with the Liquid Language. I found this by searching how to convert a string to an integer in liquid

To convert a string to a number just add 0 to the variable:

1

{% assign number = number | plus:0 %}

 

Might be worth a try. Hope that helps!

Hi, thanks for that, bu using the expression builder, I try to add what you said, but I always received an error: Invalid Syntax - Expression cannot be blank.

 

I will contact the support to see if they can help me with this and I will post the result here if anyone need it in the future :)


Thanks for your help


Reply