Skip to main content
pshashipreetham
18-Opal
18-Opal
March 8, 2021
Solved

List DropDown and Textbox Widget issue

  • March 8, 2021
  • 3 replies
  • 2220 views

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

 

Best answer by pshashipreetham

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

 

3 replies

5-Regular Member
March 8, 2021

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

pshashipreetham
18-Opal
18-Opal
March 8, 2021

Hi @mnarang 

 

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

Thanks !!

5-Regular Member
March 8, 2021

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

 

14-Alexandrite
March 8, 2021

Hi @pshashipreetham 

 

You can also try modifying your service as:

 

 

 

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

 

 

 

 

pshashipreetham
18-Opal
pshashipreetham18-OpalAuthorAnswer
18-Opal
November 27, 2021

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