how to check for a empty string

Raffi
Mega Expert

I am giving the input as numbers ...ex(11011748,11011749)

I am trying to check for an empty string.

but it returns empty , even if i enter a string.   -> (11011748,11011749)

Code sample

answer = (function () {
if(current.variables.clabel === "")    //-----> my code to check the empty string
{
workflow.scratchpad.comments = 'Given label is Receiver Label';
return 'no';
}
return 'yes';
})();

 

please help

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

simply use this

gs.nil() method

answer = (function () {
if(gs.nil(current.variables.clabel))    //-----> my code to check the empty string
{
workflow.scratchpad.comments = 'Given label is Receiver Label';
return 'no';
}
return 'yes';
})();

Regards
Ankur

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

View solution in original post

7 REPLIES 7

i tried marking both the answers a correct

 

gs.nil(current.variables.clabel))

 

current.variables.clabel.nil()

 

both seems to be correct, i tired to mark both as correct, 

but the algorithm accepts only one...

other gets disabled...

sorry for that...

 

No worries.

You can mark whichever you used and worked well.

Stay safe.

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

Aman Singh_
Kilo Sage

Hi,

 

hmm, === operator should work , but you can use gs.nil as Ankur stated or nil()

(current.variables.clabel.nil())

mark Correct/helpful if applicable, thanks!!

Aman