Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
I have a scenario where I am executing a child service (inputs: ThingShape, Thing and Boolean) from another wrapper service. Now the child service fails if I pass a ThingShape that does not exist, so I am trying to write something like:
If ThingShape Exists :
TS = TS_NAME
Else:
TS = undefined.
How do I achieve this ?
I have checked many OOTB services but none help with this.
TWX v9.3.4
Solved! Go to Solution.
if (!!!ThingShapes[TS]) {
TS = "gggg";
logger.info("ThingShape " + TS + " does not exist.");
} else {
logger.warn("ThingShape " + TS + "exists.");
}
if (!!!ThingShapes[TS]) {
TS = "gggg";
logger.info("ThingShape " + TS + " does not exist.");
} else {
logger.warn("ThingShape " + TS + "exists.");
}
It's correct, but you could simply write
if (ThingShapes[TS])
logger.warn("ThingShape " + TS + "exists.");
else
logger.warn("ThingShape " + TS + " does not exist.");
which is a bit cleaner and easier to read/less surprising (KISS principle).