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

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

@Raffi 

I could see you marked my response as correct earlier and now it is not.

Would you mind marking my response as correct as that response was given quickly and accurately. 

Regards
Ankur

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

I think it's high time now taking all these screenshot and will be tagging the servicenow on twitter and mailing the community admin as well. You really need to learn some behaviour.

Don't take it personally Aman.

I respect all the help you do for the community.

We all are here to help members.

At some places I have even mentioned that your response is proper and you should also get equal credit and recognition for your comments.

Regards
Ankur

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