Forum Discussion
FICO
3 years agoCommunity Manager
Hi, How can I run multiple "vdl-action-execute" in one "vdl-action-group", like sequential? When i put multiple vdl-action-execute in a vdl-action-group, only the first one runs. Thank you in advanc
9 Replies
- FICOCommunity Manager
Hi Narges,
I made a little demo that lets you load or run all the scenarios on the shelf:
<vdl version="5.0">
<vdl-page>
<vdl-header>
<vdl-action-group name="RUN_ALL">
<vdl-action-execute vdl-repeat="=s,i in scenarios" scenario="=i"></vdl-action-execute>
</vdl-action-group>
<vdl-action-group name="LOAD_ALL">
<vdl-action-confirm title="Loading input data" text="Loading data will override all existing input data. Do you want to proceed?" ok-label="Load Data" cancel-label="Cancel"></vdl-action-confirm>
<vdl-action-execute mode="LOAD" vdl-repeat="=s,i in scenarios" scenario="=i" suppress-prompt="true"></vdl-action-execute>
</vdl-action-group>
</vdl-header>
<vdl-section heading="Run All">
<vdl-row>
<vdl-column size="12">
<vdl-button label="Load All" vdl-event="click:actions.LOAD_ALL"></vdl-button>
<vdl-button label="Run All" vdl-event="click:actions.RUN_ALL"></vdl-button>
</vdl-column>
</vdl-row>
</vdl-section>
</vdl-page>
</vdl>
The LOAD_ALL Action group has a separate Confirm Action, you would suppress the confirmation on the Load Action so that you don't get a confirmation for each scenario.
Joc
- FICOCommunity Manager
Hi Joc,
Thank you very much for your reply.
Instead of scenarios, I want to run some custom functions (in only one scenario) on the backend so I want the "mode" to loop over. Something like this:
<vdl-action-group name="RUN_ALL">
<vdl-action-execute vdl-repeat="=i in scenario.entities.My_SET" mode="=i.value"></vdl-action-execute>
</vdl-action-group>
MY_SET keeps the name of my functions.
I tried this and it doesn't work. any idea?
I appreciate your help.
Narges
- FICOCommunity Manager
Hi Narges,
that isn't going to work I'm afraid.
The Execute VDL Action only queues a scenario for execution, at which point it is effectively locked. So, the second Execute Action fails because it is trying to execute the same scenario. However, if there are only a few permutations, you could create other execution modes to call one after another in the order you require, within the model.
Would it be possible to share a use case for wanting this functionality from VDL Actions?
Joc
- FICOCommunity Manager
Hi Joc,
I appreciate your prompt reply. Sure, this is the use case in my app:
Let’s say I have two buttons that each executes a custom function on backend.
@xi.ExecMode(name="run_fun_1")
def Fun_1 (self):
…
@xi.ExecMode(name="run_fun_2")
def Fun_2 (self):
…
Now I want to have a third button that execute these two functions, one after another. That's what I am doing.
Thank you
Narges
- FICOCommunity Manager
Hi Narges,
if the use case is that simple then the approach with a third execution mode would definitely work.
@xi.ExecMode(name="run_fun_1_2") def Fun_1_2(self): self.Fun_1() self.Fun_2()However, if there are a large number of Execution Modes and the order could be fairly dynamic then you might need to look into other methods. If there is a need for a more complex solution, let me know and I can try to help you find a better solution.
Joc
- FICOCommunity Manager
Hi Joc,
This is actually the very first thing I tried but I get like this error:
Cannot call the "run_fun_1" execution mode, because the "run_fun_1_2" execution mode is already running.
Narges
- FICOCommunity Manager
Hi Narges,
As this is Python, rather than VDL, I have asked a colleague to help you with your problem.
They should respond soon.
Best regards,
Joc
- FICOCommunity Manager
Hi Narges,
To avoid one execution mode calling another execution mode, you need to separate the logic into separate functions, like this:
@xi.ExecMode(name="run_fun_1") def Fun_1(self): self.do_1() @xi.ExecMode(name="run_fun_1") def Fun_1(self): self.do_2() @xi.ExecMode(name="run_fun_1_2") def Fun_1_2(self): self.do_1() self.do_2()Where the code that you currently have in Fun_1 is moved into a new function do_1, and the code for Fun_2 is moved into do_2.
- FICOCommunity Manager
Hi Chris and Joy,
Separating the logic worked for me and I am all set! I really appreciate you guys.
Regards,
Narges
Related Content
Related Content
VDL Actions: How to run vdl-action-execute sequentially
VDL actions are a nice addition as they allow to combine several actions behind one button. However, I couldn't make the actions run sequentially when there is (one or more) vdl-action-execute. In ...4 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2CommentsRe: Is it possible to suppress error message "Uncaught (In promise) error: the scenario is currently locked and cannot be updated" popping out at the bottom of the screen?
Thank you! This is indeed the case. I need to put the row index selected into an entity using vdl-action-update-entity command. I suppose I can move this action right before the code calls the custom...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum9 unread comments9 unread0Views0likes0CommentsHow to perform pre-check before calling custom run mode
I have a custom run mode that adds a value user entered into a list. However, I would like to check if this value already exists in the current list before calling the custom run mode. I don't think ...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum1 unread comment1 unread0Views0likes1Comment