Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
Hello,
I want to specifiy if the model has selected a sequence.
For example: If yes > show button A, if no > show button B.
I tried different ways, yet without success.
Thank you!
Solved! Go to Solution.
Hello Lily,
I solved it today. Function decide base on model widget parameter steps which is undefined when model has not a sequence (otherwise parameter is a number).
$scope.selectButton=function(){
var pom = $scope.view.wdg['model-1']['steps'];
var ButtonA = false;
var ButtonB = false;
console.log(pom);
if (Number.isInteger(pom)){
ButtonB = true;
}
else{
ButtonA = true;
}
$scope.view.wdg['visibility']['visible']= ButtonA;
$scope.view.wdg['sequence']['visible']= ButtonB;
}
The function is started when thingmak is tracked.
Best Regards,
Tomas
Hi Tomas,
For your sample, you can create two customized service, named ServiceYes and ServiceNo, with boolean output. Yes/No will be both services's input.
ServiceYes bound with button A's visible attribute and ServiceNo bound with button B's visible.
For ServiceYes, once the input is yes, return yes, if the input is no, return false.
For ServiceNo, once the input is yes, return falus, if the input is no, return yes.
After input is decided, use some event to trigger both service. Button will show up or invisible.
If you need step to step guide, just feel free to let me know.
Best Regards,
Lily
Hello Lily,
thank you for fast answer
Is possible to make decision base on model widget parameter "sequence"?
I tried to write function in Home.js which make this decision immediately after start.
This function should read value from parameter sequence I don't know the correct syntax. Then IF - ELSE will make decision based on sequence value.
I tried something like:
(function onStart(){
if ($scope.view.wdg['model-1']['sequence']==""){
setWidgetProp( 'visibility', 'visible', true);
}
else{
setWidgetProp( 'sequence', 'visible', true);
}
}
)();
Thank you,
Tomas
Hi Tomas,
Thanks for your response, and sorry that I misunderstood your question. I thought it's a ThingWorx Mashup design issue. Sorry that I am unfamiliar with ThingWorx Studio. As far as I thought Sutdio cannot be customized.
Best Regards,
Lily
Hello Lily,
I solved it today. Function decide base on model widget parameter steps which is undefined when model has not a sequence (otherwise parameter is a number).
$scope.selectButton=function(){
var pom = $scope.view.wdg['model-1']['steps'];
var ButtonA = false;
var ButtonB = false;
console.log(pom);
if (Number.isInteger(pom)){
ButtonB = true;
}
else{
ButtonA = true;
}
$scope.view.wdg['visibility']['visible']= ButtonA;
$scope.view.wdg['sequence']['visible']= ButtonB;
}
The function is started when thingmak is tracked.
Best Regards,
Tomas
Hi Tomas,
Many thanks for your sharing. It helped a lot not only me but also other customers who have the same concern.
Best Regards,
Lily