You need to sign in to do that
Don't have an account?
@taani.ax1426
how to set default value for required Field.
HI,
I want to set default value for Required field of standard object. Before insert trigger is not working on that. Help me.
Eg: There is Last name in Lead, which is required field, what my business requirement is when i click on save without entering the field value in "Last Name",trigger would update "XYZ" value in that standard field.
Hope my requirement is clear. any help would be appreciated.
regards,
Taani
one option might be to override the new buton and redirect to your standard page , passing the default value for the last name field.
You can try the below URl for populating the last name field on lead.
https://your instance /00Q/e?name_lastlea2=test
All Answers
I dont think you can do this using Standard Configuration .Moreover on Standard Sobjects required fields are uneditable to change property .
The best thing you can do is to write a trigger .Gimme some time I am working on it :)
@taani
You cannot get rid of required field validation check on Lead.LastName with use of trigger.
AFAIK, The validation is of client side and only after you save the record, the record is saved thus invoking trigger.
one option might be to override the new buton and redirect to your standard page , passing the default value for the last name field.
You can try the below URl for populating the last name field on lead.
https://your instance /00Q/e?name_lastlea2=test
Hi Prakashb,
The option you gave would be best for this issue, but the main concern is we added some custom field too, and we cant ignore that. :(
regards,
taani
Yes but any way you are redirecting only to the standard page...Just that you are sending the last name for it .
Yea, but i am unable to find my custom field on the pagelayout.
As long as you are redireccting to the same page layout , all the fields on the page layout should be visible.
Can you post the URL you are redirecting to??
Hi,
Thats worked!! grt!!, however i need to give default value for Company too...is that possible both at same time?
For prepopulating using URL you need to pass values in parameter where parementer name represent HTML ID of your field:
Lead.Company HTML Id is lea3
Yeah you can pass both in the same URL.
The id for Company field is lea3.
Superb...Thanks...!!!
HI,
how to override the standard page to that standard page with default values? Guide me
Thanks
When you click on the standard New button, note down the URL you are redirected to,
https://your URL /001/e?
In that URL set the default values has specified.
Create a new VF page wih the object for which you are going to override the button as the controller. Eg Lead.
Set action method on your page and on the action method use the below code.
public pagereference redirect(){
Pagereference p = new Pagereference(your URL);
p.setredirect(true);
return p;
}
Hi,
Check my code, getting error:(
public class thecontroller {
public pagereference redirect(){
PageReference p = new PageReference(https://cs12.salesforce.com/00Q/e?name_lastlea2=test&lea3=XYZ);
p.setredirect(true);
return p;
}
}
pls help me..
@taani, Pagereference accepts a url in String.
So, what can be done now..as i am new for this...
You should put your url within quotes.
PageReference p = new PageReference('https://cs12.salesforce.com/00Q/e?name_lastlea2=test&lea3=XYZ');
I already put,
The error i got : Compile Error: line 5:36 no viable alternative at character '"' at line 5 column 36
Can you post your latest code??
Oh sorry, by mistake i put double quote instead of single..could you please write down the code snippet for VF page for this controller..
Thanks
You can use the below code.
<apex:page controller="Lead" extension="thecontroller" action="{!redirect}">
</apex:page>
I am not getting option under 'buttons and link" to override existing page with new page. In drop down my page is not coming..any reason?
Your controller has to be the same object in which you are overriding the button.
<apex:page standardcontroller="Lead">
<apex:page controller="leadcontroller">
<apex:form >
<apex:commandButton action="{!redirect}" value="New"/>
</apex:form>
</apex:page>
this is my code, but I am unable to find this page in Buttons and link tab..what changes should be done?
Regards
If leadcontroller is your class then it has to be your extension and not a controller
<apex:page standardcontroller="Lead" extension="leadcontroller">
<apex:form >
<apex:commandButton action="{!redirect}" value="New"/>
</apex:form>
</apex:page>
Error: Unsupported attribute extension in <apex:page> in Lead_Page at line 1 column 65
Hi Prakash,
I did the same thing in my code. Its working fine.. But now i got one issue with this. These fields are not populating if i use mozilla version 21. Can you please help me how to solve this.
Thanks,
Lakshmi