Plugin Data Access under Privacy rules

Hi Bubble folks,

Is it possible to pass User rights onto my database objects ?

I have following settings:

  • A Thing Offer containing a List of Thing OfferItem under the field offer_items
  • A server-side plugin that takes a List of Offers as an input and performs a for loop on the list of Offer, in each loop I am looping on OfferItems and want to access their fields.

As soon as I set Privacy rules onto Things, the fields of OfferItems which are not passed as direct input are not readable for my plugin.

Any recommendation or best practices ?

:slight_smile:

@vini_brito @exception-rambler @keith @AliFarahat allowing myself to ping you, I saw you guys reply on this post which is not so far away from this one, maybe you’ll have time and insights to share on the question.

thks

Workflows, privacy rules, and expressions work exactly the same with plugins as with any other action. On the client side access to data is governed by privacy rules affecting the User. On the backend you can of course run backend/API workflows without the User context (“ignore privacy rules when running the workflow”).

I don’t understand what your question is, basically.

2 Likes

Hi Keith,
thanks for your answer ! You made clear the fact that I could move my workflow to the backend to go around the privacy rules, which is probably a good practice when working on data. But the practice seems to invalidate your saying.

I have done this.

  1. Created a plugin
    With offers as a List of Offers in input and 2 actions run-client-side and run-server-side (code below) that intents to access offer-items.name in a loop on offer (loop on items)
  2. I run the actions in all those combinations on
  • run-client-side in WF client side
  • run-server-side in WF client side
  • run-server-side in WF backend with offers passed from client
  • run-server-side in WF backend with offers fetched in backend

None of the three last have worked.
Preview mode: https://dataaccesswithplugin.bubbleapps.io/version-test?debug_mode=true
Editor mode: data_access_with_plugin | Bubble Editor

Do you understand the behavior at the light of what you just said about plugin ?? Do you see any pitfall in my way of testing it ?

run-client-side:
`function(properties, context) {

result_txt = ‘’;
offers = properties.offers.get(0, properties.offers.length());
for (let idx=0; idx < offers.length; idx++){

  offer = offers[idx];
  
  items =  offer.get("offer_items_list_custom_offeritems");
  items_tx = (items == null)?' is null':`has a length ${items.length()} elements`
  items_list = items.get(0,items.length());
  
  result_txt += `${offer.get('name_text')} ${items_tx}. \n `
  
  for (item_idx = 0; item_idx < items_list.length; item_idx++){
  	result_txt +=`\t Name of item ${item_idx}: ${items_list[item_idx].get('name_text')}`
  } 
  
  result_txt += '\n \n'

}

result_element = document.getElementById('resultClientSide');
result_element.appendChild(document.createTextNode(result_txt))

}`

run-server-side
`function(properties, context) {

result_txt = ‘’;
offers = properties.offers.get(0, properties.offers.length());
for (let idx=0; idx < offers.length; idx++){

  offer = offers[idx];
  
  items =  offer.get("offer_items_list_custom_offeritems");
  items_tx = (items == null)?' is null':`has a length ${items.length()} elements`
  items_list = items.get(0,items.length());
  
  result_txt += `${offer.get('name_text')} ${items_tx}. \n `
  
  for (item_idx = 0; item_idx < items_list.length; item_idx++){
  	result_txt +=`\t Name of item ${item_idx}: ${items_list[item_idx].get('name_text')}`
  } 
  
  result_txt += '\n \n'

}

return {"result": result_txt}

}

`