7

We're using list view and details OnClick Javascript buttons which reference custom js ans css files stored in static resources and containing some shared logic/styles. The sample code below demonstrates how they are referenced.

{!REQUIRESCRIPT('/resource/CustomJQuery/js/jquery-1.10.2.js')}

{!REQUIRESCRIPT('/resource/CustomLib')}

$("head").append($("<link rel='stylesheet' href='/resource/CustomJQuery/css/smoothness/jquery-ui-1.10.4.custom.css' type='text/css' media='screen' />"));

These files are also referenced in Visualforce pages.

Introduction of "Serve Static Resources from force.com domain" critical update breaking this way of using static resources in OnClick Javascript buttons - there is also Known Issue created for this https://success.salesforce.com/issues_view?id=a1p300000008XRLAA2.

So, my questions are:

1) Are there any ways to make it work with "Serve Static Resources from force.com domain" critical update activated. My assumptions for now are below, but they seem to be risky and may require significant changes:

  • hosting these js and css files on own server and referencing them in OnClick Javascript buttons and all other places;

  • move to custom visualforce pages;

2) Does anyone know what's going on with "Serve Static Resources from force.com domain" critical update right now? It was scheduled in Winter 15 first, then it was postponed to Summer 15. Now it can't be found in any org in list of all critical updates at all. It has even disappeared from the list in orgs where it used to be 1-2 weeks ago.

3) How long Known Issue can be "In review" status, since related one has this status for more than 2 months?

Thank you

2 Answers 2

2

I've raised a similar questions some time ago when I first saw that critical update:

Critical Update "Serve Static Resources from the Visualforce Domain" still serves resources via Salesforce Domain

What I got there was, that the critical update has had no impact since SF was doing a 302 redirect. In other words: turning it ON or OFF made absolutely no difference for me. The resources has been served and loaded without error.

Still I'm using Resources at several places this way and I can only confirm they are working today.

enter image description here

Also I can confirm that the Critical Update is no longer visible.

Why can't I see this Critical Update?

The Updates are only visible in a specific timeframe in which you can turn them on and off. This is very selective only to Orgs to which these updates apply and only if Salesforce decides to show them. Usually once enabled stuff from the past will disappear after that timeframe and can't be manipulated anymore.

7
  • 1) According to SF support critical update is not visible but it should be enabled by the default for orgs with Spring 15. I'm not sure why they are not giving access to activate/de-activate it manually. 2) At some point of time (e.g. 2-3 weeks ago) there was a problem with 302 redirect, that's why known issue was created before. 3) I'm not able to reproduce this Known Issue today with this critical update enabled (as well as I don't see 302 redirect now and resources are loaded from "salesforce" domain), but it's still "In review" status.
    – Victor
    Mar 11, 2015 at 16:10
  • 4) I have no ideas why hosting resources (e.g. any JS file) on own servers and then referencing them using REQUIRESCRIPT function will not help and what are the security enforcements that will prevent this? I checked referencing any other URL that is not on "salesforce" or "visualforce" domain works perfect in JS OnClick button, e.g. referencing Google CDN - {!REQUIRESCRIPT('//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js')}
    – Victor
    Mar 11, 2015 at 16:10
  • Looks like you are right for 4.) - what I said applies only to ajax calls and for iframe. I removed that part of my answer.
    – Uwe Heim
    Mar 11, 2015 at 16:43
  • 1.) I updated my answer. 2+3.) as of today: does it work or does it not work?
    – Uwe Heim
    Mar 11, 2015 at 16:56
  • 2+3) as of today I'm not able to reproduce this known issue, so it works at the moment for me. I've also noted today that resources referenced in visualforce pages using $Resources are loaded from "visual.force.com" domain as expected, while using "non best practice" reference like "!{REQUIRESCRIPT('/resource/testResource')}" still loads from "salesforce.com", so this way of using is not broken at the moment.
    – Victor
    Mar 12, 2015 at 7:08
0

As for now, the issue is not reproducible with Spring '18 release anymore, so it seems there was something internally fixed or changed in previous releases for list view buttons. Though it works now, I wouldn't recommend using JavaScript buttons including static resources with REQUIRESCRIPT function and relative URL, since this is not something formally declared and can break button with any future release or critical update. Unfortunately, $Resource global variable is not available in JavaScript buttons now. You can vote for it here https://success.salesforce.com/ideaView?id=08730000000KRuxAAG

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .