24
Views
10
Comments
Multiple server requests (Aggregates or actions) inside Client Actions

How to fix Multiple server requests (Aggregates or actions) inside Client Actions  finding in AI Mentor Studio if 2 server actions are used in a client action but none of them can be removed as both are important and work separately one is for logic and other is for exception handling


Hi @Vaibhavi Paranjpe ,
Simply you need to create wrapper actions. In a server action, you can call other server actions but in the client action try to avoid the calling of multiple server actions.

Please let me know if you have more queries.

Regards,
Anubhav

Hi Anubhav,

One server action is used for exception handling in several client actions and in each client action one other server action is used for logic so if I extract it to wrapper action it might have not work.

1) are you sure you need a server action to handle the excption on client side ?

2) making a wrapper on server side should not break your functionality, can you share more details ?  Why do you think it will not work anymore ?

3) if you really feel you must do it this way, just make sure the second exception handling server action is only called in case of an error occurring (low percentage of cases) and live with the 2 server actions in a single client action

@Vaibhavi Paranjpe ,
Could you please provide an OML or screenshot to understand this better?
What i have understood you have server actions in your exception handler also, but in this case, it will not through a warning of multiple server actions.
The exception handler is a different flow so if you have only one server action in the exception handler it will not give warning of multiple server action.

In a single flow, you need to avoid more than 1 server action.

Champion

Hi @Vaibhavi Paranjpe ,

Best solution is to use all the action inside single server action but still you don't want to do this then break sequence of 2nd action using If Condition.

Client action always gives warning when there is multiple server action in sequence. If you are using multiple server action but they are not in sequence then client action won't give warning.

Thanks

Arun

the point of warnings is to help us make sure we did not overlook anything.  Masking them with tricks or hacks is i.m.o. worse than just living with the warning in place.

Champion

Yes, you are right Dorine,

That's by i said the best way is to use all server actions inside wrapper.

Second solution suggested by me is not only about warning we can use multiple server action in same flow but it should not be in sequence.

Please correct me if I'm wrong.

Thanks

yes,

it is about the second suggestion i was talking : 

if the actual reality is that in every single execution of the client, both server actions are always called, then putting them out of sequence to fool SS is just a trick.  

The thing to avoid is doing 2 round trips to the server instead of 1.

Only scenario it is acceptable, is that they are both in different, mutually exclusive paths (2 different ends of an If, for example), never getting executed in same use case

Or possibly if one of them only gets executed sporadically (but even this scenario is improved by doing it both in a single server call)

Champion

Thanks for such a information, now I'm clear with it.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.