function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
csrcsr 

How to predefault values on fields?

How do you predefault values on fields (example: set due date on task to current date). I tried this with a trigger, but the issue is the value does not populate as soon as new is clicked (even with before insert). It is filled in only on save.

jyotijyoti

You can create a custom button that calls an S-Control with a return URL with the fields pre-populated.  For instance, you can use the below URL to create a contact with the Address information from the Account pre-populated in the Contact edit page:

parent.frames.location.replace("/003/e?retURL=%2F{!Account.Id}&con4="+acctRetrieveResults[0].Name+"&con19street="+acctRetrieveResults[0].ADDR_LN_1__c+"&con19city="+acctRetrieveResults[0].CITY__c+"&con19state="+acctRetrieveResults[0].STATE_PROVINCE__c+"&con19zip="+acctRetrieveResults[0].ZIP_POSTAL_CD__c+"&con19country="+acctRetrieveResults[0].COUNTRY_FORM__c);

Benjamin_PirihBenjamin_Pirih
In the field properities why not set the Default value to TODAY()  .. this will achieve your goal.
Mark S.ax344Mark S.ax344
But this will only work on Custom Field correct?  Standard fields don't have an option to set a default value.
Benjamin_PirihBenjamin_Pirih
You are correct about the custom fields only supporting the default value..
 
Another option is an s-control with javascript that does some ajax to lookup the value and populate the field.  It can be done..
Dave@FPDave@FP
jyoti - I tried that in every possible way I could - to no avail.
jyotijyoti

Hi Dave,  Do you want to post your URL string so we can take a look?  You may need to put the date in a variable and pass that to the URL.