apex-code

Reference a remote site setting URL in Apex class?

こ雲淡風輕ζ 提交于 2019-12-06 00:42:09
问题 I have a webservice class that will be in a managed package and distributed to multiple clients. The class currently has a variable with the hardcoded value of the server it's hitting. The problem: the server will be different for each client, so a hardcoded value will not work. I figured since each client will have to add their server to their remote site settings, the easiest way might be to grab the correct URL from their setting. Is this possible? Or is there another "right" way to

Overriding properties from abstract class in Salesforce Apex

与世无争的帅哥 提交于 2019-12-05 17:23:08
I have an abstract class in apex with several properties that I would like to override in a child class. According to the documentation, properties support both the override and virtual access modifiers. However, when I try to use either of them in either the parent or child class, I get an error saying that variables cannot be marked as virtual/override. Here is a facsimile of the code that causes this error: public abstract class Row{ public virtual double value{ get{return value==null ? 0 : value;} set; } } public class SummaryRow extends Row{ private list<Row> childRows; public override

Organizing Apex Classes under Namespace

寵の児 提交于 2019-12-05 15:16:33
问题 Is there any way in Salesforce to group apex classes under a package or namespace? Can we use managed package for internal organization purpose? 回答1: This is a limitation in the force.com stack that makes medium-large size projects painful, if not impractical. Using managed packages in order to get a package prefix doesn't really solve any problems, so it's not really worth the trouble. I usually try to organize a project into one flat level of namespaces. In lieu of actual namespaces, I'll

Parsing JSON Object in Salesforce Apex

青春壹個敷衍的年華 提交于 2019-12-04 21:57:39
问题 How do I parse a jsonObject which is in a given format in Apex? I need List<String> from the items array which contains the id attribute. What is some appropriate method? For parsing it, I try to create a class with code: public class JSON2Apex { public class Items { public String kind; public String etag; public String id; public String status; public String htmlLink; public String created; public String updated; public String summary; public String description; public String location;

How to convert Salesforce rich text editor to a “full mode” editor?

强颜欢笑 提交于 2019-12-04 12:29:42
With the spring '12 coming over these days, the old "hack" to convert the rich editor will not work any more. What can be done to retain full CKEditor functionality after spring 12? New CKEditor is object rather than URL based and a new approach is needed. In case anyone needs it, the following script will replace factory editor layout with a full version allowing additional formating options (fonts, colors, etc). Note, I set the height to 600px, adjust for your own needs. Also, as before, this can only work in your own VF pages, you cannot change the behavior of "factory" page layouts. $

Reference a remote site setting URL in Apex class?

旧城冷巷雨未停 提交于 2019-12-04 06:55:00
I have a webservice class that will be in a managed package and distributed to multiple clients. The class currently has a variable with the hardcoded value of the server it's hitting. The problem: the server will be different for each client, so a hardcoded value will not work. I figured since each client will have to add their server to their remote site settings, the easiest way might be to grab the correct URL from their setting. Is this possible? Or is there another "right" way to accomplish this? Thanks The best way I've found to save configuration values is to use Apex Custom Settings .

Creating a test class for a Select Statement

*爱你&永不变心* 提交于 2019-12-04 06:20:40
问题 I was wondering if you could help me. I am strugging to create a test class for the code below. Any help would be appreciated. Many thanks public class MatchReadyImage { public Match_Day_Check_List__c obj {get; set; } public MatchReadyImage(){ obj = [ Select Id, Match_Day_Ready_Status__c From Match_Day_Check_List__c Where Name = 'Everton V West Ham United Goodison Park EPL 2013-05-12' ]; } } 回答1: You just need to create a test data which will be selected by your code, because the data from

CSRF safe Custom button linked to Apex method

て烟熏妆下的殇ゞ 提交于 2019-12-04 04:44:32
I'm looking for a technique to execute Apex code from a custom button added to the Opportunity object in a way that protects the user against CSRF. The current approach being used comes from the question - Custom Button or Link to a Visualforce page with a custom controller . Essentially: There is an Opportunity Custom Button with the Content Source set to "Visualforce Page". The Content for this button is set to a Visualforce page that uses Opportunity for the standardController, has an extension apex class entered and an action for a method in that class The action method returns a

Apex Code Version Control

筅森魡賤 提交于 2019-12-04 04:27:57
Is there any way to integrate version control system for Apex & Visualforce code? I can thinking of keeping a separate repository but no way to have it integrated with Salesforce Platform. Thanks in Advance. You can do this by using Subversion and the Force.com Eclipse IDE with the Subclipse plugin. Here are a few links to some instructions. Setting up Subversion (Windows) Installing Force.com IDE (Eclipse) Installing Subclipse (Eclipse plugin) Use the update site when installing in Eclipse - similar to the instructions here If instead of using Subversion, you wish to use Git (lots of the

How to implement “Cancel” functionality in a VisualForce Page

好久不见. 提交于 2019-12-04 04:02:39
I know that this is how to save a record <apex:commandButton action="{!save}" value="Save"/> I want a button to NOT save the current record (ie. Cancel) and navigate to the list of saved record (ie. list of objects for that object type). Something like this... <apex:commandButton action="{!cancel}" value="Cancel"/> The list view for an object is your base URL / the 3 letter prefix for your object / o, for example: https://na1.salesforce.com/a0C/o So you could just create an action method that returns a Pagereference with the appropriate URL and set to redirect ( pr.setRedirect(true) ).