cancel
Showing results for 
Search instead for 
Did you mean: 
Security Alert Log4j Security Vulnerability. Click here to know more.
cancel
Showing results for 
Search instead for 
Did you mean: 

List DropDown and Textbox Widget issue

psp316r
14-Alexandrite

List DropDown and Textbox Widget issue

I am giving an output of the Textbox and the Dropdown to a Service, based on the input the operations are performed in the service.

Issue:

How Can I know if there is nothing entered in the Textbox or Dropdown.

if(Textbox==="" || Dropdown === "")
{
//Do Nothing
}
else
{
//Do Operations
}

But always the it's going in to the if condition only. 

How Can I check if the INPUT of the Widgets(Textbox and Dropdown) is Empty(no input given) or not

 

1 ACCEPTED SOLUTION

Accepted Solutions
psp316r
14-Alexandrite
(To:psp316r)

Hi,

This issue is solved by following Code Snippet:

if(!Textbox || !Dropdown)
{
//Do Nothing
}
else
{
//Do Operations
}

 

The '!' checks for null, undefined and empty string.

Thanks,
Shashi

 

View solution in original post

5 REPLIES 5
mnarang
17-Peridot
(To:psp316r)

can you try this from JS service and first test it from composer directly? you can take 2 service inputs as TextBoxInput type string and DropDownInput as type string. You can check the logger in script logs, please make sure script log logging level is warn or above.

 

if(TextBoxInput==null || DropDownInput==null)
{
logger.warn("either text box or drop down is empty");
}
else
{
logger.warn("Atleast there is a value");
}

psp316r
14-Alexandrite
(To:mnarang)

Hi @mnarang 

 

This is the first option I have tried, but this doesn't work at all.

Thanks !!

mnarang
17-Peridot
(To:psp316r)

May i know on which Thingworx build you are trying this? This is working fine on my TWX server(9.1).

 

suverma
12-Amethyst
(To:psp316r)

Hi @psp316r 

 

You can also try modifying your service as:

 

 

 

if(TextboxInput == undefined || TextboxInput == "")
{
//Do Nothing
}
else
{
//Do Operations
}

 

 

 

 

psp316r
14-Alexandrite
(To:psp316r)

Hi,

This issue is solved by following Code Snippet:

if(!Textbox || !Dropdown)
{
//Do Nothing
}
else
{
//Do Operations
}

 

The '!' checks for null, undefined and empty string.

Thanks,
Shashi

 

Announcements