Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Issue with rawValue data getting repeated

Mahesh_Krishnan
Level 2
Level 2

The Value within Quotes get repeated twice. Any idea?

if(this.rawvalue != null){

     this.rawValue = "/ " + this.rawValue;

}

Desired Result = / SampleData.

Obtained Result = / / Sample Data. The "/ " gets repeated twice.

1 Accepted Solution
radzmar
Correct answer by
Level 10
Level 10

To test against null you should use the operator !== instead of !=

If (this.rawValue !== null) {

     this.rawValue =  "/ " + this.rawValue;

}

Well, this propably wont avoid the slash gets repeated because the script will add an extra slash every time it is fired.

You'll need to check the current value for an slash atthe beginning using a regular expression like:

/^\//g

The script the could like like:

If (this.rawValue !== null) {

     If (!this.rawValue.match(/^\//g)) {

          this.rawValue =  "/ " + this.rawValue;

     }

}

View solution in original post

1 Reply
radzmar
Correct answer by
Level 10
Level 10

To test against null you should use the operator !== instead of !=

If (this.rawValue !== null) {

     this.rawValue =  "/ " + this.rawValue;

}

Well, this propably wont avoid the slash gets repeated because the script will add an extra slash every time it is fired.

You'll need to check the current value for an slash atthe beginning using a regular expression like:

/^\//g

The script the could like like:

If (this.rawValue !== null) {

     If (!this.rawValue.match(/^\//g)) {

          this.rawValue =  "/ " + this.rawValue;

     }

}

View solution in original post