I saw a post on IdeaJam asking for a solution to this problem.
The thing is: if you have an action button on top of an embedded view and this button tries to run code that refreshes or saves the uidoc (t.i. the document that has the embedded view on it), this will crash your client.
This is exactly the situation I was in: I needed a refresh or save in the containing document after pushing the button Add Checklist:
My client crashed everytime I tried to use a uidoc.Refresh or uidoc.Save. I first tried to put the button above the embedded view, that way the code ran ok, but the problem is: how do you explain this to the user? All action buttons are located above the embedded view, except for one? “Is this a joke?”, he will ask.
Then I tried to move all buttons outside the embedded view. New problems rised: my code didn’t work the same way, and I had to find new workarounds for this.
Then I put the button on a layer: you can’t see it in the screenshot, but the first button is actually in a layer floating on top of the embedded view. Here’s a screenshot of it in Designer:
However, this needs some tweaking if you want your user not to notice the difference with a real action button in an embedded view:
- Positioning: I use 2 layers: one layer (the container) with autopositioning, and a second (contained) layer with fixed positions (I had to go through some trial and error to position it right, but it’s doable). Also, I let a dummy action button (without any code behind it) to leave some open space for the button.
- Color and style: I matched the layer background color with the color of the actionbar. For the style for Action Bar – Button Options, I used Display border – Never. The layer button is actually a hotspot, which resembles most to this kind of action button. I also added the icon in the layer.
I won’t say this is the solution to all problems, but it might solve some of these embedded view/uidoc related issues.