In our database User has a field called “Plan” which is another object in bubble. However after assigning the Plan to the User as below, the plan field of the user is still empty. Any ideas?
Hi there, @saasbox… does the debugger give you any clues as to why the assignment is failing? Are you sure a plan is being returned in the search? Do you have any privacy rules in place on the Plan or User data types that could be getting in the way?
Thanks for the reply @mikeloc. I checked and there are no privacy restrictions, debugger evaluates the right side to a valid plan. Is that the right way to assign a thing as a field on another thing? Next I am going to try a simpler assignment to see if that works.
Well, it’s the right way if it assigns the appropriate plan to the current user, so in this case, no, it’s not the right way.
Kidding aside, if the plan field on the User data type is linked to the Plan data type, and if the search evaluates to a valid plan, then it should work in theory. What is the constraint on the search?
Perfect. So, you sign the user up, set fields, create a new plan (if it does not exist) and want to assign that user the plan that was just created, right?
If yes, you can do the following
In the Assign Plan to User action you do: Plan = Result of Step 4's Plan
I don’t think that’s going to work because I assume step 4 is a custom event, and to the best of my knowledge, you can’t reference the result of a custom event. So, @saasbox, you might try adding a step to the custom event that assigns the newly-created plan to the user only when the result of the step that creates the plan is not empty. Then, change step 5 to search for the appropriate plan to assign to the user only when the user’s plan is empty (which it will be if the custom event finishes without creating a new plan and assigning it to the user).
The issue with this is Step 4 creates the plan only if it doesn’t exist, so the result of Step 4 is not always a plan. Step 5 re-queries the plan to assign it.
Querying the plan is done as shown. In the debugger evaluating by clicking on “first item” does show the plan, but somehow assignment doesn’t work. (no errors seen)
The issue was the Search for Plans query. SaaSBoxId is a UUID saved as text in the database:
The same field “user plan id” is used to save the value for SaaSBoxId when creating the plan in the previous step. Unfortunately querying the same value right after (as I shared in the earlier message) does not work.
What worked was querying it by the name field as here: