Skip to main content
Mar 8, 2021 8:33 AM UTC
Solved

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

 

Nov 27, 2021 10:03 AM UTC

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

 

5 replies

Mar 8, 2021 9:42 AM UTC

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");
}

Mar 8, 2021 9:57 AM UTC

Hi @mnarang 

 

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

Thanks !!

Mar 8, 2021 10:06 AM UTC

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

 

Mar 8, 2021 3:33 PM UTC

Hi @pshashipreetham 

 

You can also try modifying your service as:

 

 

 

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

 

 

 

 

pshashipreethamAuthorAnswer
Nov 27, 2021 10:03 AM UTC

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