Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top