# Return server side action value to element method in plugin

**URL:** <https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840>\
**Category:** Plugin builders\
**Created:** [February 20, 2023, 10:18am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840 "2023-02-20T10:18:03Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kishanm](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kishanm](https://forum.bubble.io/u/kishanm)\
**Post date:** [February 20, 2023, 10:18am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/1 "2023-02-20T10:18:03Z")

</div>

Hello,  
I am creating a plugin in which I created an element and server side action.  
Server side action is used to make external request and get data(array), now I want to access this data to update/initialize method of the element.

Is there any way to achieve it using coding? Or any other way?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 20, 2023, 11:23am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/2 "2023-02-20T11:23:49Z")

</div>

There is no communication between server side actions and elements.  
Server side actions return data. If you want to pass that data to an element you need to do it with an action inside a workflow in bubble.  
If your request doesn’t have private data you can make it from a client side action of your element. This way you have access to the element’s data object.

---

<div class="post-metadata">

**Author:** ![kishanm](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kishanm](https://forum.bubble.io/u/kishanm)\
**Post date:** [February 20, 2023, 11:30am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/3 "2023-02-20T11:30:02Z")

</div>

> [@dorilama](#):
>
> inside a workflow in

Thanks for your reply. Can’t use element action because I request with private data.  
Would you please share more how can I pass data to element using workflow?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [February 20, 2023, 12:53pm UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/4 "2023-02-20T12:53:54Z")

</div>

In any way you prefer using normal bubble workflows and depending on how you organize the logic in your code.  
for example let’s assume your plugin element has a field `name` and your server action returns a string:

- create a custom state of type string
- set the field `name` to this custom state
- in your workflow call the server action
- use the set state action to set the custom state with the string returned

There are also other ways. Experiment ans see what works for you.

Cheers  
Mariano

---

<div class="post-metadata">

**Author:** ![kishanm](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kishanm](https://forum.bubble.io/u/kishanm)\
**Post date:** [February 20, 2023, 12:57pm UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/5 "2023-02-20T12:57:47Z")

</div>

Let me try this. Thanks @dorilama

---

<div class="post-metadata">

**Author:** ![kishanm](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kishanm](https://forum.bubble.io/u/kishanm)\
**Post date:** [March 15, 2023, 8:21am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/7 "2023-03-15T08:21:59Z")

</div>

Hello @dorilama,

The given solution works. I have created field and custom state and received the data into element method.

Now, In server side action- A set workflow to call the server side action on page load. So, every time action will be called on page load. I want to add if condition here, Like if i refresh the page first time and got response from external api then set this response(like in cookie) if it is set then next time request shouldn’t send on page load.  
Please guide how I can store response of set flag to restrict server side call form 2nd time on page load?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [March 15, 2023, 8:54am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/8 "2023-03-15T08:54:08Z")

</div>

You should implement that with bubble logic, not with the plugin. You may want to store the data you need in the database and conditionally call your actions based on that.

---

<div class="post-metadata">

**Author:** ![kishanm](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kishanm](https://forum.bubble.io/u/kishanm)\
**Post date:** [March 15, 2023, 9:08am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/9 "2023-03-15T09:08:05Z")

</div>

Is it possible to store data into database from plugin action?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [March 15, 2023, 9:15am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/10 "2023-03-15T09:15:26Z")

</div>

No, it’s not possible, unless you want to use Bubble’s data API and make direct requests to it from your code, but at that point you also need to handle the authorization yourself.

---

<div class="post-metadata">

**Author:** ![kishanm](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kishanm](https://forum.bubble.io/u/kishanm)\
**Post date:** [March 15, 2023, 9:21am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/11 "2023-03-15T09:21:24Z")

</div>

Ok. thanks for reply.  
I have a one last question. Which would be the best way to implement SSO(single sign on) by using bubble as sso provider? I want to implement sso to my plugin.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [March 15, 2023, 9:31am UTC](https://forum.bubble.io/t/return-server-side-action-value-to-element-method-in-plugin/247840/12 "2023-03-15T09:31:15Z")

</div>

There is a lot of topics about that in the forum. You can search for it and then decide what you like more. 🙂
