Wednesday, December 4, 2013

Assign default value to any field in Edit mode

Create Home page component with type 'HTML Area'.


Add below line of code in 'Show HTML'.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">  
var j$ = jQuery.noConflict();      
j$(document).ready(function(){      
    j$('#00N90000003CEbd').val('Medium'); //To set Custom field value
    j$('#acc23').val('Test');  // To set Standard Field value
});
</script>

Custom Field :
Here, '00N90000003CEbd' is the SFDC id of the custom field.

 

Standard Field:
To set standard field default value, 1st get id of that field using firebug and after that use that id in code and assign value.(refer below snap)




Here, 'acc23' is the id of the Account Site.

Result:


Consideration:
  • Make sure that sidebar is enabled for user.
  • Custom component is added in sidebar and it is visible in all pages.

No comments:

Post a Comment