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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Has the model a sequence?

TomasCharvat
14-Alexandrite

Has the model a sequence?

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!

ACCEPTED SOLUTION

Accepted Solutions
TomasCharvat
14-Alexandrite
(To:liliu)

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

View solution in original post

5 REPLIES 5
liliu
12-Amethyst
(To:TomasCharvat)

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

TomasCharvat
14-Alexandrite
(To:liliu)

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

liliu
12-Amethyst
(To:TomasCharvat)

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

TomasCharvat
14-Alexandrite
(To:liliu)

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

liliu
12-Amethyst
(To:TomasCharvat)

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

Announcements

Top Tags