Why it is not possible to use $public outsystems react API in Screen Actions?
Application Type
Reactive

I want to use $public Javascript API in my Client Actions. Such as $public.Navigation and $public.Validation. 

If I use $public api in Javascript block directly on a screen or on a block then it works perfectly. But when I move the same javascript block on a client action then it stops working.

Is there anything I can do so the $public API works from the Client Actions and not only from Screens/Blocks?

ok, I had some more time : you could retrieve the $public object at screen level and store it in a local variable of type object in your screen.

Each client action that you want to use on the public api, takes in an input variable of type object.

Pass this into your javascript and use it instead of $public.

Dorine


EDIT : see attached oml

OSPublicApIissueShowcaseWithObject.oml

mvp_badge
MVP

Hi Maksym,

You are not sharing code or error messages you get, making it hard to see what goes wrong. But what you do should work. You should be able to use the API in the JavaScript widget in client actions. Maybe you are forgetting to use the $resolve(); in your JavaScript.

See for info https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_and_Reactive_Apps_Using_JavaScript/Defining_Asynchronous_JavaScript_Code

Regards,

Daniel


Hi Daniël Kuhlmann ,

Sorry for the inconvenience. I'm providing here the module illustrating my issue with Validation and Navigation API I was talking about.

I've created 2 buttons where the javascript block is inside the screen acitions (Screen actions section) - Works.

Another 2 buttons (Client actions) calling the same javascript but in Client Actions - Not Working.


Please let me know if something is still unclear.

OSPublicApIissueShowcase.oml

Hi Maksym,

the problem is not getting to the $public api itself, you can for example use the feedbackMessage from a client action.  I think the problem is context/scope, the client actions scope probably doesn't have a notion of the current screens widgets etc.

See attached your oml extended, where i tried a few more things.  So from a client action you can use the feedback message from the api, and if you use webblocks instead of client actions to make it reusable, you can do the navigate, and for the invalidate, you get a different error now.

Don't have time to explore further,

Dorine

OSPublicApIissueShowcaseExtended.oml

Is there something that we could do to pass that context somehow from the screen or block to the client action so that $public js actions would start working from there?

ok, I had some more time : you could retrieve the $public object at screen level and store it in a local variable of type object in your screen.

Each client action that you want to use on the public api, takes in an input variable of type object.

Pass this into your javascript and use it instead of $public.

Dorine


EDIT : see attached oml

OSPublicApIissueShowcaseWithObject.oml

Ok thanks, it looks like a solution. But now If I want for example to put this logic in some common block (or layout) on a screen then it only works for Navigation and not for Validation. I think in order for it to work for Validation you need to actually get the $public from the screen context and not from the block.

I've tried to set the $public to window global variable from the block and use that in the client actions. Please see the attached oml.

OSPublicApIissueShowcase.oml

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