function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suhas GB 4Suhas GB 4 

Critical Update - Hyperlink Formula Fields for JavaScript Disablement

How the Javascript will be there in the HYPERLINK function. Please give an example for this. What is the solution for this.
Please share an example of HYPERLINK in which Javascript is used.
Thanks in advance
Abhishek BansalAbhishek Bansal

Hi Suhas,

You can get the complete information about this in the knowledge article present on the link given below:
https://help.salesforce.com/articleView?id=000249336&type=1 (http://​https://help.salesforce.com/articleView?id=000249336&type=1)

Hope this will help you.

Thanks,
Abhishek Bansal.

Chellappa NagarajanChellappa Nagarajan
Hi Abhishek,
Just to clarify, you posted a link which talks about blocking javascript in HYPERLINK.
Suhas,
Based on the link, you may want to skip this idea and implement your requirement through other means.
Thanks,
Chellappa
 
AlvaroCostaAlvaroCosta
Example of formula field with JS: HYPERLINK("javascript:if(typeof(srcUp)=='function') {srcUp('/" & Id &"');}" + " else {window.open('/"& Id &"')}", "LINK TO SUBTAB", "_blank" )
ChellappaChellappa
Hi Alcosta, 
Abhishek and Myself didn't give the example because this feature is going to be disabled or discontinued soon by Salesforce.
So i would not recommend Suhas to use this option .
Thanks,
Chellappa
Devalkumar ShahDevalkumar Shah
Hi Everyone.

Salesforce has provided below code to identify the Hyperlink/java script formula field in our org..

// 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); } } }

But the problem is my org is too big, so i am getting CPU timeout error.

For this error salesforce has mention "If your org has a large number of custom objects, you might encounter an Apex CPU limit error when you run the script. If so, you can modify this code to split the list of entities and run it for each subset of entities"

So my question is how to modify code to split the list of entities and run?

Thanks
Deval