By default, application-level JavaScript modules apply to all sites in your Commerce Cloud instance. You may override this default and assign an application-level JavaScript module to be used on only specified sites. To do this, you issue a POST request using the updateSiteAssociations custom action of the applicationJavaScript resource and provide a list of sites in a sites property. For example, the following request updates myJSModule.js to execute on siteA and siteB only.

POST /ccadmin/v1/applicationJavaScript/myJSModule.js/updateSiteAssociations

{

  "sites": ["siteA", "siteB"]

}

To remove site associations, issue a POST request using the same custom action with the sites property set to null:

POST /ccadmin/v1/applicationJavaScript/myJSModule.js/updateSiteAssociations

{

  "sites": []

}

The following is an example response for a call using the updateSiteAssociations custom action:

{
  "result": true,
  "links": [
    {
      "rel": "self",
      "href": http://localhost:9080/ccadmin/v1/applicationJavaScript/
demo.ko.extenders.js/updateSiteAssociations"
    }
  ]
}

To retrieve a list of all application-level JavaScript modules along with the sites they are associated with, issue a GET request to the applicationJavaScript resource. An empty sites list means that a module will be loaded on all sites.

GET /ccadmin/v1/applicationJavaScript

For example:

{
  "items": {
    "ext.ko.extenders.js": {
      "sites": []
    },
    "ext.shared.viewmodels.js": {
      "sites": [
        "siteUS"
      ]
    }
  },
  "links": [
    {
      "rel": "self",
      "href": http://localhost/ccadmini/v1/applicationJavaScript/?sites=siteUS
    }
  ]
}

Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices