I have a dashboard that shows a users dashboards and reports in the app. I can click the object I want and it will call a custom command that uses the REST api to make the permission change. This works fine with the command being invoked in a panel that is hidden until an object is selected.
However when I implement a modal pop up that has the REST api call search defined and ran in a .js file, I sometimes get a 404 and 409 error when changing the objects permissions. But the objects' permissions are still successfully changed.
Edit: I checked the internal log and when I run the custom command via the javascript file, it calls the REST API 3 times. Running it from a dashboard always runs it once.