URL tweak to assign a default value to a field when a page loads

There are certain times when you would want certain fields in a web page to have default values. In other words, when a certain page loads from the apex class or JavaScript, there might be some fields in it where you want default values to be present without the user having to modify them. In this case, adding the API name of the field at the end of URL will not populate the field.

In order to get the desired results (default text in fields), a little tweak in the URL is needed. This solution works well when there is less number of fields to populate with default values. To implement this solution, you have to get the html id of the field to be updated and include that field in the URL.

Instructions on implementing the above solution with an example –

For example, if the field “Average_Review_Score” in the below screenshot has to be defaulted to value “10” on page load.


When you right click on the field (that should contain the default text) and select the option ‘inspect element, which is a feature available in Google chrome and Firefox, the html ID of the element will be displayed on the browser as shown in the below screenshot.


You will have to copy the ‘ID’ of the element and paste it at the end of URL assigning it to the required value.

na17.salesforce.com/a02/e?retURL=%2Fa02%2Fo (URL before editing)

na17.salesforce.com/a02/e?retURL=%2Fa02%2Fo&00No0000005mamc=10 (URL after editing)

Reload the page to see the default value populated on the page layout as under –