181
Views
13
Comments
Can we use single client action in multiple web blocks?

Can I create single client action and call in in different web blocks ? Like I create a validation client action now I want to use it in different web blocks. What is the solution and best approach to use client action ?

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

You can create a client action on the logic tab, that you call in the block client actions.

Regards,

Daniel

2018-10-29 08-31-03
João Marques
 
MVP

Hi Navneet,


You can re-use a client action in multiple blocks or screens.

You can't however re-use a screen client action in other scopes than the block or screen it belongs. In a screen client action, which you will see under the block or screen, in the Interface tab, you will be able to have access to the screen scope (data point and aggregates outputs, input variables and local variables, screen widgets):


While a client action is not bound to the screen, you don't have access to the screen elements. You can however, use input and output parameters to make it generic, like a client action that receives a URL, and opens it in a new tab. It doesn't use any screen element and can be re-used.
These client actions, you'll find them under the logic tab:



Kind Regards,
João

2022-12-30 07-28-09
Navneet Garg

how can I call this in input event like onkeypress ?

2022-12-30 07-28-09
Navneet Garg

Ok but can we access these client actions in the element events like onchange event ? As I mentioned that I need to use it for validation like input field validation (onkeyup event). So how can I access it as I checked it is not available in the selection.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

yes why not, you could just tried to find it out yourself.

2022-12-30 07-28-09
Navneet Garg

I tried but it is not available in the selection popup.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Is the client action you try to use in your block action in the same module?

If it is in another module then you first need to reference it.

2022-12-30 07-28-09
Navneet Garg

Yes, it is in the same module. I need to use it in difference web blocks in same module.

I created a client action ValidateDateInput. Now in webblock1 I want to validate input field using this validation. and same thing I want yo do in webblock2.

UserImage.jpg
Nani

Client Action you can use "n" number of time in same module or other module.
Just create a screen action where you want to use client action and call the client action in screen action.
that's it, it's done.

2023-03-16 16-29-51
Paulo Rosário

Hello Naveet, 

The reason you cannot see the client action on the dropdown options is that those events only have access to actions on the screen in which they exist.

What you can do is create a Client action in the screen ( LocalValidate for example ) that calls the one you created in the Logic tab ( GlobalValidate), this way you can reuse the logic in all the screens. 

Hope it helps!

Paulo Rosário

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

Maybe I don't understand your issue, but I can create a client action on the Logic tab (SharedClientAction) and then select it inside an action of a block. See screen shot and attached OAP. This are just the basic concept of OutSystems code reusability.

Regards,

Daniel

ReuseClientActionDemo.oap
2024-09-12 02-43-38
Deepsagar Dubey

Yes, it's a basic concept of code Re-usability, 

Hi Navneet, Are you still facing the same issue then elaborate more in which scenario you can't do like that.  

2023-05-08 05-34-05
Piyali Saha

Hi Navneet,

Yes, you can definitely reuse the client action in multiple blocks. If you are still facing the issue kindly share your oml.

Thanks & regards 

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