How to get position of '/' in a text using glidefunction:position() and then use it in substring

Not applicable

Hi,

 

I want to get the position of '/' in a text using the glidefunction:position().And then want to use it in substring.

Tried to escape the value but it returns error/garbage value. I cannot use other javascript functions because only basic functions are included in reports.

Code:

glidefunction:substring(category,'0',position('/',category))

Eg. I have string - 'Network Services / VPN / Cloud'

       So after the code execution I want to display only - 'Network Services'

 

How can we do this ? Thanks in Advance 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@Community Alums 

try this

glidefunction:substring(category, '1', glidefunction:subtract(position('/', category), '1'))

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Sohail Khilji
Kilo Patron

Hi @Community Alums ,

 

Can you try this :

glidefunction:substring(category, 0, glidefunction:position(category, '/'))

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Not applicable

Hi @Sohail Khilji 

I tried the solution, but its giving syntax error.

glidefunction:substring(category, 0, glidefunction:position(category, '/'))

 When I removed glidefunction keyword before position, then syntax error got correct. But still it did not give the expected output. I tried below codes:

glidefunction:substring(category, 0, position(category, '/'))
glidefunction:substring(category, 0, position( '/',category))

Ankur Bawiskar
Tera Patron

@Community Alums 

try this

glidefunction:substring(category, '1', glidefunction:subtract(position('/', category), '1'))

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Community Alums 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader