Shailesh Deshpande
  • Member for 9 years
  • Last seen more than a month ago
  • London, UK
How do we get the last day of the month from a given date
48 votes

You can also use: yourDate.addMonths(1).toStartofMonth().addDays(-1). This will give you the last day of current month. What this basically does is it adds 1 month to current date and then use the ...

View answer
How to include a report in a VisualForce Page
Accepted answer
9 votes

You can use analytics:reportChart instead. <apex:page> <analytics:reportChart reportId="01Z5B0000004w7B" > </analytics:reportChart> </apex:page> analytics:reportChart ...

View answer
NOT IN based on another query?
9 votes

A simpler way would be to form a set or list of strings which correspond to the Ids for of Me_MyCustomObject__c and then use it in the where clause of the query: for example: List<...

View answer
soql query to all contacts where lastname = firstname
9 votes

This is not allowed in SOQL. Please refer the below link which confirms the same. https://developer.salesforce.com/docs/atlas.en-us.200.0.soql_sosl.meta/soql_sosl/...

View answer
Filter list view - comparing custom user lookup to logged in user
Accepted answer
5 votes

Create a formula field (IsItemOwnerLoggedInUser?) with return type as checkbox and set it to true for currently logged in user. Item_Owner__c == $User.Id Create a new view and in the filter criteria,...

View answer
How to convert a lookup field into a autocomplete field
5 votes

Try this out: Setup -> customize -->search settings -->check lookup autocompletion for whichever objects you wish. This will automatically search for records as user types in characters. I checked ...

View answer
Apex Test Class Question on Changing Account Owners
Accepted answer
4 votes

I wonder why you would want to write a trigger to achieve this functionality. If Account owner is changed, the owner of associated contacts is automatically changed. Please refer below article for ...

View answer
Lead Status Converted Value to Contact Status
4 votes

From the docs: When you convert a lead, data in standard lead fields is transferred into standard account, contact, and opportunity fields. For custom lead fields, the data is mapped to custom ...

View answer
profile object permissions for a detail record
Accepted answer
4 votes

This refers to objects which are related by the master detail relationship. In case of such relationships we have two objects - parent ( usually referred as Master) and child(referred as detail). When ...

View answer
How to restrict uploading exe file in salesforce
Accepted answer
4 votes

We can control the download behaviour of the files using configuration(Point & Click). However as far as i know we do not have any standard declarative way in which you can control the file to be ...

View answer
org wide defaults for an object explanation of settings
Accepted answer
4 votes

What you expect to see depends upon what you have set for the OWD. Organization Wide Defaults apply to your entire org by default. When defined as: Public Read ONLY - Anybody(All users having access ...

View answer
system.listException:List Index out of Bounds:1
4 votes

You are using the same loop variable "t" for referencing the elements of both "transactions" and "camp1". Also you are using the size of "tranactions" to iterate over. However, it may not always be ...

View answer
How far in the future are @future annotated methods executed?
4 votes

The time is not gauranteed. It usually executes immediately in few seconds, however, as they are executed asynchronously, the time is not gauranteed. Also, remember that any method using the future ...

View answer
How to Create a Date Input Field
3 votes

There are several ways in which you can achieve this. If you want to mimic datepicker which is seen in salesforce UI, the simplest one is as suggested by @Boris in his answer. The other ways ...

View answer
Is there any way to modify Standard profile
3 votes

NO. We cannot modify "Standard Profiles". The only way to achieve this is to "Clone" the standard profile, modify the permissions on the cloned profile and assign the cloned profile to the user. From ...

View answer
SOQL - PermissionAssignmentSet
Accepted answer
3 votes

Please use Assignments. The below query works: Select Id, (Select Id, PermissionSetId, AssigneeId, Assignee.FirstName, Assignee.LastName, SystemModstamp From Assignments) From PermissionSet p

View answer
How to create custom buttons
3 votes

I would suggest you to follow the below path: Setup --> Create --> Objects --> select any object --> Custom Buttons and Links --> New On this page at the top right, click on "Help for this page". ...

View answer
User role is grayed out when setting up another admin
3 votes

May I know what license have you assigned to the user? Based on the License you will get to see the profiles. You need to assign the 'Salesforce' license to your user. Then you will see the 'system ...

View answer
Standard Datepicker Year values
3 votes

Here's one Workaround i found out in one of the blog. Note: This will not work if your the "sidebar" attribute in your page is set to "false".

View answer
How to get the Latest Task created on Lead
3 votes

You could use a subquery in this case. This query will fetch all the tasks for the lead. you wil have to order the results by Created Date and then limit it to 1. List<Task> latestTasks = new ...

View answer
Prepopulate fields on standard layout but before that allow selection of record type
Accepted answer
3 votes

Assuming that you are using a custom button to navigate to the page, all you need to do is to copy the link that you get when you click the "New" button for that object. And use it in your custom ...

View answer
How to begin with salesforce certifications?
2 votes

This has been asked several times on stackexchange. You might want to look at the below links: How to study/prepare for the Salesforce Developer Certification Salesforce certified Administrator or ...

View answer
I got null value from component attribute
Accepted answer
2 votes

I have faced similar issues earlier when using components. Seems, we are not able to use {get;set;} when working with components. Please try changing the below line from your code public String ...

View answer
how to compare time only from Datetime field in SOQL
2 votes

I am not sure if the "bookingDate" in your system is populated manually or via some logic. If it is done manually, then one way to do this would be to create a Number field on the object say "...

View answer
How to Prevent the System.QueryException
2 votes

I dont know whether this is a best practice or not but, whenever i have encountered such error or rather always, i use a List instead of the object itself. and then later on in the code, check whether ...

View answer
how to cover Id!=null part in test Class
2 votes

Add the below code before calling initializing the demoClass. Apexpages.standardcontroller controller = new Apexpages.standardcontroller(newinvoice); democlass policy = new democlass(controller); ...

View answer
Number field without comma (thousands separator)
2 votes

You can use apex:outputText tag to format the output. Try this out: <apex:outputText value="{0, number, 000000.00}"> <apex:param value="{!numberfield}" />

View answer
How to write Wrapper Class and using Visualforce page to display multiple objects data. Best Practises
1 votes

The wrapper class that you define will vary and depend on what you wish to achieve. However, a common structure that most wrapper classes will follow is as below. public class OuterClass{ //...

View answer
I am trying to insert text into a rich text area field which has string '\\n' in the text. However salesforce is ignoring everything after \\n. Ideas?
1 votes

For the rich text field you will need to use HTML equivalent of new line. You will have to replace the \n with br in your code. Please try below: String s = 'Test \n String'; s.replaceAll('\n', '<...

View answer
Access *View All* in Administrative Permissions in all profiles through SOQL
1 votes

You can use below query: Select Name, PermissionsViewAllUsers, PermissionsViewAllData From Profile

View answer