How to use the ExecutePS function in selfVM
No edit summary
No edit summary
Line 1: Line 1:
This is a practical reference example on how to use the ExceutePS function from a viewmodel. There are many possible uses but this is one that is fairly descriptive I think.
This is a practical reference example of how to use the ExceutePS function from a ViewModel. There are many possible uses, but this one is fairly descriptive.


Need: Look up all the objects that has the same value as one particular object. Maybe the user wants to know if something is unique or not…
Need: Look up all the objects with the same value as one particular object. Maybe the user wants to know if something is unique or not…


Model:
Model:
Line 9: Line 9:
[[File:Execute -2.png|none|frame|419x419px]]
[[File:Execute -2.png|none|frame|419x419px]]


So what happens is that we set the vValueToMatch to the Attribute1 of the viewmodel root Thing. Then we call the ExecutePS, stating that it will get a result collection with objects of type Thing if it runs the expression found in OutOfLoopToAvoidStdFetch.col1. We collect over this result and add the objects to a list we added as a variable – vMyList.
What happens is that we set the vValueToMatch to the Attribute1 of the ViewModel root Thing. Then, we call the ExecutePS, stating that it will get a result collection with objects of type Thing if it runs the expression found in OutOfLoopToAvoidStdFetch.col1. We collect this result and add the objects to a list we added as a variable – vMyList.


That list can act as root for Grid in the UI.
That list can act as a root for Grid in the UI.


If we have a million Thing-objects in the database – this viewmodel will only load the ones with the same attribute1 as the the Thing object we started with.
If we have a million Thing objects in the database – this ViewModel will only load the ones with the same attribute1 as the Thing object we started with.


See [[OCLOperators_ExecutePS]]
See: [[OCLOperators_ExecutePS]]
[[Category:OCLPS]]
[[Category:OCLPS]]
[[Category:View Model]]
[[Category:View Model]]

Revision as of 08:01, 21 February 2023

This is a practical reference example of how to use the ExceutePS function from a ViewModel. There are many possible uses, but this one is fairly descriptive.

Need: Look up all the objects with the same value as one particular object. Maybe the user wants to know if something is unique or not…

Model:

Execute -1.png

ViewModel:

Execute -2.png

What happens is that we set the vValueToMatch to the Attribute1 of the ViewModel root Thing. Then, we call the ExecutePS, stating that it will get a result collection with objects of type Thing if it runs the expression found in OutOfLoopToAvoidStdFetch.col1. We collect this result and add the objects to a list we added as a variable – vMyList.

That list can act as a root for Grid in the UI.

If we have a million Thing objects in the database – this ViewModel will only load the ones with the same attribute1 as the Thing object we started with.

See: OCLOperators_ExecutePS

This page was edited 90 days ago on 02/10/2024. What links here