Skip to main content

Hello,

 

I was recently given the task to build a Workflow in Freshservice that can set and remove Roles for Agents. Trigger for this should be a specific Service Request being raised.

Currently I am having trouble with adding this new role to the existing role array. Here are the relevant parts of my Workflow

  1. First I use the API to get the Agent details that include their roles
  2. Then I use the following parser node (narrowed down to the attributes I need)

 

But then I have the problem of how to add the new role

{ "role_id": 53000134485, "assignment_scope": "entire_helpdesk", "workspace_id":2 }

to the existing array that I can then write back.

Expression Builder is not usable for my Use case, since outputting any String with the Expression Builder turns every double quote inside the String into a single quote

 

And the Web Request body only accepts double quotes since this is the JSON standard.

 

With Liquid alone I wasn’t able to find a way to insert this new role into the the Array (also tried handling the role array as full String but also did not work).

Does anyone have an idea on how I could try to implement this, or is it just not possible due to the limitations the Workflow builder and Liquid have? If needed I can also share the Liquid methods I tried with. 

Here you have a post similar you are looking for Expression builder, String output with double quotes? | Freshworks Community 


Hello @CMagin, if you know the values you want to pass to the Freshservice API you could save the values in a custom object and then use a reader node to get to that record, giving you the option of passing the value in your JSON object.


Hello,

thanks for your replies.

The post @Daniel Söderlund mentioned is indeed similar and helped me in the beginning of my tests.

To go into a bit more detail to what I have tried already:

This is an example role attribute I receive from the Web Request fetching the Agent details:

"roles": ":{"role_id": 53000082528, "assignment_scope": "entire_helpdesk", "groups": "], "workspace_id": 2}]"

To write this back I need to remove the “groups” attribute (since you can’t set it if the scope is entire helpdesk). So I added this Liquid filter (Parser node shown in my inital post):

"roles": {{P1.root.agent.roles | replace: ',"groups":"]', "" }}

This is working fine to just write the role array back without changing anything else. But now I want to add this fixed role

{"role_id":53000134485,"assignment_scope":"entire_helpdesk","workspace_id":2}

to the Array so it looks like this:

"roles": "r{"role_id": 53000082528, "assignment_scope": "entire_helpdesk", "workspace_id": 2}, {"role_id": 53000134485, "assignment_scope": "entire_helpdesk", "workspace_id": 2}]"

As far as I know Liquid doesn’t provide any methods to add a new item to an Array, and when I tried to use replace like this

replace: '}]', '},{"role_id":53000134485,"assignment_scope":"entire_helpdesk","workspace_id":2}]'

it also does not work since Liquid does not support replacing a curly brace (https://github.com/Shopify/liquid/issues/213).

Do you have any other ideas?


Hi @CMagin. Were you able to get this resolve? We are in a similar situation for providing a service for Managers to provision agent roles and group via approval workflow but run into issues building the json like you. 

So far we only made progress with making it in Powershell but since the Powershell orchestrator isn’t exactly secure yet we don’t want to use it unless we have to. 


Reply