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
Amita TatarAmita Tatar 

Setting default value for start date on edit page

Hi guys,

i have a requirement where i want to set default date as today's date on order object start date field. How can i do that? Can u please help?
Shailesh PatelShailesh Patel
Shailesh Patel
Put  code in Controller
public Object edc{get;set;}
Controller(){
edc.Date__c=System.today(); 
}
Vfpage

 <td > <apex:inputField value="{!edc.Date__c}" /></td>

If you want to put when page is edited, put code in edit method
Hope this will be help you!!!
 
Amita TatarAmita Tatar
Hi Shailesh,

I want this for standard order page layout .I to set default value for the field Order Start Date on order page layout
Shailesh PatelShailesh Patel
Hi Amita,

Orderstartdate is standard required field of order object. you cannot make its default.
 
Amita TatarAmita Tatar
Hi Shailesh,

Is there any way to remove the field from layout? So that i can create a custom field and set a default value for it?
Siddharth ManiSiddharth Mani
Couldnt find a direct way to do this. But there is a workaround mentioned in:
https://developer.salesforce.com/forums?id=906F00000008jTlIAI
What you need to do is:
1. Create a new VF Page with the below code :
<apex:page standardController="Order" action="/801/e?EffectiveDate={!TODAY()}&nooverride=1&retURL=/801/e">
</apex:page>
This assumes:
a. You are using standard Order Object and "Order Start Date" field.
b. You need to change the "action=" part as per your org details (/801/e would be the part where you click on New button from the Order tab, EffectiveDate should be same if youa re using standard field. Change the "retURL=" part as well to redirect to the New Order creation page). 

2. Override your standard "New" button using this page created above.

Let me know if this works for you!