Hot answers tagged

38

Salesforce uses a simplistic method for calculating storage usage. Most records use 2KB of space despite how many fields are actually used. There are a few exceptions to this rule. See "What are the various record sizes?" on Salesforce for which objects take more or less space. Person Accounts - 4KB Campaigns - 8KB Campaign Members – 1KB Articles - 4KB ...


37

For Hierarchy custom settings, you can get an instance, then populate and insert it: //fetches or creates a Custom Setting at the organization level HierarchySetting__c setting = HierarchySetting__c.getOrgDefaults(); setting.CustomField__c = 'http://salesforce.stackexchange.com/'; upsert setting; Or with List custom settings: new one up with the fields ...


36

Create an object called AccountHistoryTracking and fields like APIName__c,OldValue__c,NewValue__c then create a fieldset on Account called'HistoryTracking' with the fields you want to track on Account and then write below code to track history on account.This way you don't need to worry about history tracking limit per object. trigger AccountHistoryTracker ...


17

You can achieve this by passing the values to the standard field id's in the url. This technique is known as Salesforce URL hacking. It is described in detail in this excellent blog post by Ray Dehler. In this instance, you'd retrieve the standard id of the "Amount" field, and then use this Id in the url to assign a static value to the Amount field. ...


15

LastModifiedDate is the date the record was last updated by a user. SystemModstamp is the date the record was last modified (by a user, workflow, trigger, etc.).


15

There is no CreatedBy object --- the CreatedById reference field, along with LastModifiedById and OwnerId, is (except in rare cases) a reference to the User object. Thus, querying for CreatedBy.UserName on the CaseComment object is requesting the UserName field of the User record who created the CaseComment record. If you were thrown off by the lack of a ...


13

There are a lot of ways you could tackle this. What have you tried to solve this problem so far? How about using the monthsBetween function, and then adding your requirement about a small number of days difference counting as an additional month? Date a = Date.newInstance(2013,10,7); Date b = Date.newInstance(2014,1,12); Integer monthDiff = a.monthsBetween(...


11

Try using string.valueOf(variableName); That should solve your problem.


11

User input for a percentage field is to represent the percentage as a whole number. .1 = .1% 1 = 1% 10 = 10% 100 = 100% Worth mentioning also that the value retrieved from the DB comes out in the same format, you need to convert by dividing by 100 yourself.


10

By Default no profile can see Encrypted Data. Only those profile which has “View Encrypted Data” permission can see encrypted fields and by default this permission is not given to any profile. You have to active this permission in profile by checking “View Encrypted Data” check box . For more detail See this link Encrypted Field Details


10

In this instance the documentation is correct. Ultimately they are putting \n\r to represent a "new line". When you split the lines, you are looking at \n. This will cause each line to start with \r and is not impacting the way you are reading the string lines in your code.


10

For some reason, Salesforce does not allow you to make a number of types required. It's no use asking why. Workaround: make a validation rule that checks whether this field is filled.


10

You want to call getRelationshipOrder() from your describe. It will be null for a lookup, 0 or 1 for a Master-Detail relationship.


9

The System Fields documentation covers this (sort of): http://www.salesforce.com/us/developer/docs/api/Content/system_fields.htm CreatedBy is the relationship to the User identified by the CreatedById on the record.


9

Looks like theres 3 methods you can use to check the definition of a textarea: field.getType() == Schema.DisplayType.TEXTAREA field.isHtmlFormatted() field.getLength() Here's a snippet of these methods in use: if (field.getType() == Schema.DisplayType.TEXTAREA) { if (field.getLength() <= 255 && !field.isHtmlFormatted()) { return '...


8

You will likely be using the fields collection. This is the only bit currently still constrained by the governors in this area for some reason. Take a look at, Understanding Apex Describe Information, specifically section Using Field Describe Results Schema.DescribeFieldResult F = Schema.SObjectType.Account.fields.Name; The best thing to do is get the full ...


8

I think you can infer it, if a field is Createable and not Nillable and not DefaultedOnCreate. SObjectType.Account.Fields.Name.Createable && !SObjectType.Account.Fields.Name.Nillable && !SObjectType.Account.Fields.Name.DefaultedOnCreate The DescribeFieldResult does not surface this directly (thanks Farid Kognoz) If you don't mind to use ...


8

@sfdc's method will consume a lot of Data Storage -- and that's expensive! Do what @sfdc said but store the data in JSON in a Long Text Area Field on the record. Then build a Visualforce Page that displays the JSON in a readable way.


8

The best thing I came across is https://schemalister.herokuapp.com/. No installation required since it is hosted as a Heroku app.


8

You can track upto 20 standard and custom fields per custom object. To track field history for custom objects: From Setup, click Create | Objects. Click Edit next to the name of the custom object. Select the Track Field History checkbox. Click Save. Click Set History Tracking in the Custom Fields & Relationships section. This section allows you to ...


7

Yes, you can use {!$ObjectType.SOBJECTNAME.fields.FIELDNAME.label} eg {!$ObjectType.Account.fields.Phone.label} To iterate over all the field labels for Account Map<String, SobjectField> fieldMap = Account.getsObjectType().getDescribe().Fields.getMap(); for(String f : fieldMap.keySet()) System.debug(fieldMap.get(f).getDescribe().getLabel()); ...


7

There are a few different Developer Edition templates floating about, and which one you'll get is determined by the link you used to access the Developer Edition sign up page. The usual one, found on developer.force.com, will always come with the same custom fields, classes, and so on. Every once in a while, special templates are distributed to showcase a ...


7

Monitor Setup Changes Setup Audit Trail tracks the recent setup changes that you and other admins have made to your org. Audit history is especially useful in orgs with multiple admins. To view the audit history, from Setup, enter View Setup Audit Trail in the Quick Find box, then select View Setup Audit Trail. To download your org’s full setup ...


7

Here's a way that you can achieve this. Let's say I have the component as below. There's a field for Title, which is hidden when the component is rendered (and your use case is to enable that). This approach also makes sure that all your standard validations are taken care of, viz., required fields, email formatting (in the example below). Component: <...


6

Look in the code that you have not done any describe call inside the for loop Schema.DescribeFieldResult F = Account.AccountNumber.getDescribe(); This is an example for field describe .Search for the describe calls in the code and make sure we have out of the for loop. http://www.salesforce.com/us/developer/docs/apexcode/Content/...


6

The only fields that appear only on detail pages, and not edit pages, are formula fields. For normal fields, you may choose to make the fields read-only, in which case they will appear, but not be editable by the user. One possible solution is to have two fields per entry: a formula field and the actual underlying data value. You can have two different ...


6

If it is required at field level or it is a Master-detail lookup then it is automatically added to the layout and you wont be able to remove it.


6

Only marking fields as external ids as you pointed out is the only way an end user can have a field indexed. Other fields such as lookups (and master detail relationships) are indexed automatically. For what you are requesting there's really only 2 options. Create a snapshot like sobject / table to have less records you'll need to filter through for ...


6

Take a look at this help article: Considerations before having Create Audit Fields enabled: Salesforce has the ability to set system fields through the API. When you are migrating data from an external system, the API lets you set a number of fields on objects that were previously read-only. By setting these fields, records will appear to have been ...


6

You can use the allowFieldTruncation header in the DMLOptions Class. Order record = new Order(...); Database.DMLOptions opt = new Database.DMLOptions(); opt.allowFieldTruncation = true; Database.insert(record, opt); If you're dong this from elsewhere (e.g. the API), there are similar headers you can use for allowFieldTruncation to prevent errors from ...


Only top voted, non community-wiki answers of a minimum length are eligible