Question

Extract numbers from comma-separated list

  • 23 June 2023
  • 3 replies
  • 80 views

Userlevel 1
Badge +3

Can anyone with expression skills help me? I have a node in a workflow that retrieves the “in use” assets for someone who’s leaving and asks the manager to return them.

What I’d also like to do is change the status of the assets to something like “awaiting return” using an API call but I can’t work out how to extract the separate asset display IDs from the comma-separated list…I can grab them all from a parser node and end with something like “[ 12345,67891,2345 ]” (if that person has three assets.)
Any ideas...thanks!


3 replies

Userlevel 7
Badge +11

Hi.

Not sure how your timings for this request are, but FreshWorks is currently working on a Offboarding process that will be released soon.

Hopefully, this would be addressed with this upcoming feature.

 

Regards,

Userlevel 6
Badge +11

Can anyone with expression skills help me? I have a node in a workflow that retrieves the “in use” assets for someone who’s leaving and asks the manager to return them.

What I’d also like to do is change the status of the assets to something like “awaiting return” using an API call but I can’t work out how to extract the separate asset display IDs from the comma-separated list…I can grab them all from a parser node and end with something like “[ 12345,67891,2345 ]” (if that person has three assets.)
Any ideas...thanks!

Hi @jonathan.allison - if you can’t wait for the new feature, do you  have a sample of the workflow to share that would be quite helpful.

If your WF pulls those asset IDs in an expression node you can then use them as parameters in an action node in the same WF and then send them out in an email.

This is a very useful expression that captures everything between 2 consistent markers i.e. “Updated Client Name:” and “Previous Client Name:”  - you must include everything in the line for the demarcation to work properly.

substring('{{ticket.description}}', (indexOf('{{ticket.description}}','Updated Client Name:',0)+20), indexOf('{{ticket.description}}',' Previous Client Name:',0))

 

Description field content:
Description

Client: GUID
Client Name : SOME OTHER CLIENT
Environment: LIVE
Requester: Bryn@somedomain.com

Name changed
Updated Client Name: SOME OTHER CLIENT
Previous Client Name: SOME CLIENT

 

PS I just noticed that I hadn’t updated my email to include the info from a new expression node! lol

HTH
Bryn @ CYDEF.ca

Userlevel 1
Badge +3

Hi @BrynCYDEF 

Thanks for your reply. It’s just an API GET request on the requester’s ID to return all the assets they have...most people have a laptop and a phone so will have at least two, so it’s returned as an array when I use {{P1.root.assets.assets_object.name}} or {{P1.root.assets.assets_object.displayid}} from the parser node afterwards which is okay for information but difficult to do anything with on the specific assets.

I’ve actually managed to bodge it by having multiple parsers after the GET and specifying which number in the array each one handles, so $.assets[0].name, $.assets[1].name etc. instead of $.assets[*].name. Seems to work okay anyway.

Intrigued what the new offboarding feature will be...I was at a user group with them last week for joiners/movers/leavers and it wasn’t mentioned!

Cheers.

Reply