1

I got an email from Salesforce stating that my org has JavaScript in hyperlink formula fields and that they would no longer be supported by October.
How do I find these? What is the solution?

I am in Classic. Here is the relevant article:

Salesforce will block JavaScript execution in hyperlink formula fields via a phased approach. Salesforce defines these fields as custom hyperlink formula fields starting with the string "javascript:"

Phase 1: Starting with the Spring '17 release, admins will be unable to create new hyperlink formula fields containing JavaScript. Editing and saving existing fields containing JavaScript will also be prevented unless the JavaScript is being removed. This change will not impact packages, sandboxes or change sets.

Phase 2: In the Summer '17 release**, a Critical Update Console (CRUC) setting will be introduced, allowing admins to opt-in to blocking the execution of JavaScript in hyperlink formula fields by activating the CRUC.

Phase 3: The phased approach will conclude with the Winter '18 release*** when execution of JavaScript in hyperlink formula fields will be prevented.

** Currently targeted for June 2017; date subject to change
*** Currently targeted for October 2017; date subject to change.

4

There's no easy way to identify these, so you'll have to manually search for them or check out your documentation.

Ideally, your org's been documented by someone in a wiki, and you can easily identify these fields. You'll need to either remove them or update them to not use JavaScript. The exact method depends on the formula's behavior. The most likely solution as a replacement will be a Visualforce page that does whatever the current script does.

If you don't have any documentation, you'll have go at it the hard way. That is, you'll need to download the Force.com IDE, download all of the objects, standard and custom, into your local file system, and search for the term 'javascript:' (no quotes) to find possibly offending fields. From there, you should be able to identify which objects have these fields, and the fields' names, at which point you can fix them or remove them as necessary.

If you need help converting a specific formula to a future-compatible format, please feel free to ask a separate question including the formula's code so that we can assist you.

  • 1
    Man, that would be really ideally. Documentation is usually...lacking. – Adrian Larson Feb 17 '17 at 17:25
  • Thank you for your reply. There is no documentation of my org. The lightning readiness report gave me the JavaScript buttons. I am looking to know what a javascript hyperlink formula field looks like and how to rectify it. Any examples? – Heather Donelson Feb 20 '17 at 16:22
  • @HeatherDonelson a formula would look like this: HYPERLINK("javascript:doSomething()"). As the related document says, you should probably just be able to pull in all fields in the Force.com IDE, and do a global search (Search > File...) for the exact string "javascript:" (without the quotes). – sfdcfox Feb 20 '17 at 16:29
0

Apex code to find formula fields containing javascript:

// Get all the standard and custom objects in the org

List<EntityDefinition> entityDefs = [select QualifiedApiName from EntityDefinition];


// Forming a list of Entity API names

List<String> entityNames = new List<String>();

for(EntityDefinition entityDef: entityDefs){

 if(!entityDef.QualifiedApiName.endsWith('kav')){

      entityNames.add(entityDef.QualifiedApiName);

 }

}

// Make the describe call

Schema.DescribeSobjectResult[] results = Schema.describeSObjects(entityNames);


System.debug('Got describe information for ' + results.size() + ' sObjects.');

// Check if there is a formula field with JavaSscript used in the HYPERLINK function

for(Schema.DescribeSobjectResult res : results) {

 Map<String, SObjectField> fields = res.fields.getMap();

 for(String fieldKey: fields.keySet()){

      SObjectField sField = fields.get(fieldKey);

      Schema.DescribeFieldResult fieldResult = sField.getDescribe();


      // This will have the formula string for fields of type Formula

      String calculatedFormulaString = fieldResult.getCalculatedFormula();


      // If the formula uses a HYPERLINK function with javascript vbscript or data protocol

      // it cannot be used for security reasons

      if(null != calculatedFormulaString 

           && calculatedFormulaString.startsWithIgnoreCase('HYPERLINK')

           && (calculatedFormulaString.containsIgnoreCase('javascript:')

                || calculatedFormulaString.containsIgnoreCase('vbscript:')

                || calculatedFormulaString.containsIgnoreCase('data:'))){

           System.debug('Object name: ' + res.getLabel());

           System.debug('Field name: ' + fieldKey);

           System.debug(calculatedFormulaString);

      }

 } 

}
  • dumping code as a solution without any explanation is not very useful, someone might copy paste it and expect it to work then come back here and ask why its not working or how to use it. Please provide details other than code comments and proper usage of it. Thanks! – glls Aug 17 '17 at 0:49

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.