Remove Leading 0's from Alphanumeric String - Javascript | Community
Skip to main content
Level 4
February 17, 2022
Solved

Remove Leading 0's from Alphanumeric String - Javascript

  • February 17, 2022
  • 1 reply
  • 2660 views

Hello, 

 

I wrote the following JS so I can remove leading zeroes from an Alphanumeric field. However when I run the code - the field is not dropping the leading zeroes. 

 

Instead I get the same value. I feel like I'm missing something. The field I'm loading is a string value, but it looks like the replace is being ignored. 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Amine_Abedour

Hello @montezh2001 

 

the type of your ''res'' variable is xml and the replace function works only on string variables. You have to convert your xml variable to a string one like this :

var res = results[0].@image1.toXMLString();

 

result : 

 

Br,

 

Amine

 

1 reply

Amine_Abedour
Community Advisor
Amine_AbedourCommunity AdvisorAccepted solution
Community Advisor
February 17, 2022

Hello @montezh2001 

 

the type of your ''res'' variable is xml and the replace function works only on string variables. You have to convert your xml variable to a string one like this :

var res = results[0].@image1.toXMLString();

 

result : 

 

Br,

 

Amine

 

Amine ABEDOUR
Level 4
February 17, 2022

This worked. Thank you. I knew I was missing something small. 

Thank you so much! 

 

I also ran it this way based on a recommendation, and this worked as well. 

 

var res = new String(results[0].@image1)