Which section I put script so that it will execute before view or sandbox view

How to restrict user not to drag more than one dashboard on the template.
For Example, I took a 3*3 template and put the dashboard one by one on each container. But I want to restrict user if he/she already drag dashboard on specific container then he/she will not able to override another dashboard. If he/she wants to drag he/she has to delete the previous one.

For warning, I wrote a code but don’t know where to put that script.

I only aware of scripts that run when the dashboard is in view mode, they do not execute in edit (that would be annoying while trying to change them and write them, actually in most cases it would make it impossible to work on the dashboard).

I would think this is would have to be in the .net API area but I do not see anything right off that would do what you are wanting.
.NET API

If no other answer here send in a support ticket, this is an interesting idea. What is the use case and need for it?

just thought of the overrides file, hold on I got to find it on the support site
Ok it not as clear as I hope, you should get with support.

Does not look like that will would work either:
" JavaScript added to the file [BIWebsite]\Scripts\Override\javascript.override.js will be executed when the page loads.

You could choose to use this file to define your own set of common functions in a global variable that can then be called by scripts on dashboards and other views."

Thanks James. I will raise a support ticket. I also find this scenario an interesting one. Let’s see any thing will come from dundas support.

Something like this isn’t supported because you are asking to change the behaviour of the actual dashboard designer. But… Dundas BI allows you to apply any JavaScript that you’d like so you can override the behavour.

PLEASE NOTE : THIS CODE IS BEING PROVIDED as-is and should give you some idea of how to approach this.

To get your desired effect, you would have to override canvas.onDrop and mark .originalEvent.preventDefault as true when a user script has detected a sub-canvas is already present. The current functionality will bandon the drop when e.defaultPrevented==true or e.originalEvent.defaultPrevented == true

For example, in the ready action:

var canvasService = this.getService(“CanvasService”)
var canvas =canvasService.canvas;

//save a reference of the original onDrop function call
var origOnDrop = canvas.onDrop.bind(canvas)

//override the onDrop call with a new functionality that would abandon the drop action when a flag indicating an existing embedded dashboard is true
canvas.onDrop = function(callback, e) {
if (!!embeddedDashboardAlreadyExists && !callback ) {
e.originalEvent.preventDefault();
e.preventDefault();
}
//call the original onDrop
origOnDrop(callback, e)

}

No promises on this one but hopefully this will at least give you something to try.