Solved

Extract number from string

  • 25 September 2023
  • 2 replies
  • 82 views

Badge

I am trying to get the umber from the string but getting the “Invalid Syntax - One of its operands is invalid.” error, will someone help me with this.

substring('Your request to Terminate for Test User ID number 12345',indexOf(length(replace('Your request to Terminate for Test User ID number 12345 has been approved and has completed','has been approved and has completed','')),'number',0)
)

 

icon

Best answer by Daniel Söderlund 26 September 2023, 09:54

View original

2 replies

Userlevel 7
Badge +13

I am trying to get the umber from the string but getting the “Invalid Syntax - One of its operands is invalid.” error, will someone help me with this.

substring('Your request to Terminate for Test User ID number 12345',indexOf(length(replace('Your request to Terminate for Test User ID number 12345 has been approved and has completed','has been approved and has completed','')),'number',0)
)

 

You posted this in the Freshdesk forum :) 

Is the string fixed ? 
Just like to remove the tex in front of the number?

If it’s that you can do like this

{{ticket.subject | remove: ‘Your request to Terminate for Test User ID number ’ }}

That will give you the number only. 

With expression I should dom something like this 

substring('Your request to Terminate for Test User ID number 12345',
indexOf('Your request to Terminate for Test User ID number 12345',
'number ',0)+length('number '),
length('Your request to Terminate for Test User ID number 12345')
)



 

Badge

Thanks Daniel it works

Reply