0

In a site collection there is a particular subsite where I need to apply a UserCustomAction. It will be a basic JavaScript function that prompts for acknowledgement and sets a cookie. The need to do it as a custom action is so no matter where the user lands in this web, it will fire, not just on the home page.

The only other UserCustomAction I deployed was as an app for a site collection that was a singular web.

My concern is that if I set a UserCustomAction on a web, it will somehow bubble up to other webs in the collection which isn't desirable.

Looking at vgrim's gist, it looks like this will be the case, but can anyone confirm this?

  • 1
    Hold on.. I now see something 'bubble' as well.. be back – Danny '365CSI' Engelman Apr 29 '16 at 16:40
  • A test on another site that mimics the desired implementation seems to indicate it won't bubble. I welcome the results of your test (and a link to the custom action editor if it is a public release :-) ). – Eric Alexander Apr 29 '16 at 17:13
  • send me a private message and you can help iron out the bugs.. all my alfa code is public.. you only have to know where to look :-) – Danny '365CSI' Engelman Apr 29 '16 at 17:38
3

I am no exeprt yet, but spent the last days on CustomActions and REST because the New Library View has nothing SharePoint left but CustomActions (and no JSOM on the page it for creating/changing them)

There are two types of CustomActions/Scriptlinks involved here:

  • Type 2 = Site(Collection) Executes on every page inside the SiteCollection

    /_api/site/usercustomactions

  • Type 3 = Web Executes on every page inside the Web it was created (not in its subsites!!)

    /_api/web/usercustomactions

So the endpoint you use determines what you create and where it gets executed

Built your endpoint with _spPageContextInfo.webAbsoluteUrl or _spPageContextInfo.siteAbsoluteUrl

(2 and 3 are internal numbers, I don't know what 1 may be, Farm?)

Proof:

I have 2 CustomActions in the Root of the SiteCollection:

Both get executed

SubSite (Web)

Reading all CustomActions in the Web:

The WEB CustomActions from the parent site are NOT executed.

These (sub)WEB CustomActions where NOT executed on the parent.

Notes

  • the Sequence number determines the load/exeution order.. lower numbers first (in screenshot Sequence should be 10 and not 1, it is a later screenshot taken)
  • you can create UPPERCASE names, but the call will be lowercase (as IIS is not case sensitive no problem; but external links must be lowercase files.
  • yes, CustomActions you set on non-New-Library-View pages with JSOM or Powershell are fired on the View page (But lets not call it a View page, as it is not a WebPart View)

REST syntax for creating CustomActions: https://msdn.microsoft.com/en-us/library/office/dn531432.aspx#bk_UserCustomAction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.