Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

can we put custom date field & custom picklist field with no's in it. IN start(SartDateTime) field in event object with trigger code. plz can any one provide me with a sample code please

when event is created for opportunity, date field and picklist field should override the star feild and populate the custom fields values.

share|improve this question
    
Do you want to autopopulate a date field and a picklist in an event related to an opportunity when the event is being created? Your question is too confusing to understand what you really want !!! –  rao Dec 20 '12 at 17:50
    
sorry nothing related to opportunity im sorry abt that. i have a 2 custom fields in event object 1 is date field ohter is pick list field when event is created start field is default field we cannot save the record with out values in it so i want to override the start field with those custom fields –  rakesh Dec 20 '12 at 17:53
    
This is doable by overriding the newevent button with a vf page where we can pass the start value through the URLFOR() and using $Action.The part I do not get is when you say you On create the other 2 fields need to be copied over to the event start date, where will the other 2 fields get the value from? –  rao Dec 20 '12 at 17:58
add comment

1 Answer 1

Step 1: Create a VF page like : New_event_Override:

<apex:page standardController="event" action="{!urlredirect}" extensions="event_override">
</apex:page>

controller:

public with sharing class event_override {
public date custom_date;
public string custom_picklistval;
    public event_override(ApexPages.StandardController controller) {
    custom_date = date.newInstance(2012, 11, 30);
    custom_picklistval = '07:00 AM';
    }
    public pagereference urlredirect(){
    Pagereference page = new pagereference('/00U/e');
    page.getparameters().put('StartDateTime',string.valueof(custom_date.format()));
    page.getparameters().put('StartDateTime_time',custom_picklistval);
    page.setredirect(true);
    return page;
    }
}

NOTE : The way I get the 'StartDateTime' and 'StartDateTime_time' is by going to the input field next to the start right clicking on the field and inspecting element in chrome ( this gives the Id of the field , which we can override)

share|improve this answer
    
Hi rao, can we do this operation with trigger –  rakesh Dec 21 '12 at 9:07
    
populating data on trigger on create is possible, pl breif more on what you want so that i can try to help you. –  rao Dec 21 '12 at 9:11
    
in the event field start is the mandatory field without entering the values we cant save the record. what im looking for is i created a date field(Date__c) and time__c fiels(Picklist with hours ex: 01,02,03...59) after entering the values & click save values of date field and time field should display in start field with over riding the start values –  rakesh Dec 21 '12 at 9:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.