Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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
Solved! Go to Solution.
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
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 !!
May i know on which Thingworx build you are trying this? This is working fine on my TWX server(9.1).
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