cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

List DropDown and Textbox Widget issue

pshashipreetham
17-Peridot

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

 

Shashi Preetham
1 ACCEPTED SOLUTION

Accepted Solutions

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

 

Shashi Preetham

View solution in original post

5 REPLIES 5

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

Hi @mnarang 

 

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

Thanks !!

Shashi Preetham

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

 

Hi @pshashipreetham 

 

You can also try modifying your service as:

 

 

 

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

 

 

 

 

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

 

Shashi Preetham
Top Tags