You need to sign in to do that
Don't have an account?
kuldeep paliwal
i create an custom object with some custom fields on custom object i override the new button now how i save the record
public class NewDulplicateBusterJobController{
private String BusterJobName;
public String getBusterJobName() {
return this.BusterJobName;
}
public void setBusterJobName(String BusterJobName) {
this.BusterJobName = BusterJobName;
}
public NewDulplicateBusterJobController(ApexPages.StandardController controller) {
selectedObject = 'account';
getObjectFields();
}
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public SelectOption[] selectedFields { get; set; }
public SelectOption[] allFields { get; set; }
public String message { get; set; }
Public NewDulplicateBusterJobController(){
}
public List<SelectOption> getObjectNames(){
List<SelectOption> objNames = new List<SelectOption>();
for (Schema.SObjectType obj : schemaMap.values()){
Schema.DescribeSObjectResult describeSobject = obj.getDescribe();
String Name = describeSobject.getName();
String Label = describeSobject.getLabel();
if(Name == 'Account' || Name == 'Contact' || Name == 'Lead' || Name == 'Opportunity' || Name == 'Case' || Name == 'KnowledgeArticle' || describeSobject.isCustom()==true){
SelectOption so = new SelectOption( Name , Label );
objNames.add(so);
objNames.sort();
system.debug('--objNames--' +objNames);
List<SelectOption> allFields = getObjectFields();
}
}
return objNames;
}
public List<SelectOption> getObjectFields(){
selectedFields = new List<SelectOption>();
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
allFields = new List<SelectOption>();
for (String fieldName: fieldMap.keySet()) {
allFields.add(new SelectOption(fieldMap.get(fieldName).getDescribe().getName(),fieldMap.get(fieldName).getDescribe().getName()));
allFields.sort();
}
return allFields;
}
}
<apex:page standardController="Buster_Job__c" extensions="NewDulplicateBusterJobController" > <apex:form > <apex:pageBlock title="Duplicate Filter Edit"> <apex:pageblockButtons location="top"> <apex:commandButton value="Save" /> <apex:commandButton value="Save & Start" /> <apex:commandButton value="Cancel"/> </apex:pageblockButtons> <apex:pageBlockSection title="Filter Name" collapsible="false" columns="2"> <apex:pageBlockSectionItem > <apex:outputLabel value="Buster Job Name:"></apex:outputLabel> <apex:inputText title="Buster Job Name" value="{!BusterJobName}" required="true"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Select Standard or Custom Object" columns="2"> <apex:pageBlockSectionItem > <apex:outputlabel value="Object:"/> <apex:actionRegion > <apex:selectList value="{!selectedObject}" size="1"> <apex:selectOptions value="{!ObjectNames}"/> <apex:actionSupport event="onchange" rerender="myFields"/> </apex:selectList> </apex:actionRegion> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Select a Field and Its Rule"> <apex:pageblocksectionitem > <apex:outputPanel id="myFields"> <c:MultiselectPicklist leftLabel="Available Fields" leftOption="{!allFields}" rightLabel="Selected Fields" rightOption="{!selectedFields}" size="14" width="150px"/> </apex:outputpanel> </apex:pageblocksectionItem> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
private String BusterJobName;
public String getBusterJobName() {
return this.BusterJobName;
}
public void setBusterJobName(String BusterJobName) {
this.BusterJobName = BusterJobName;
}
public NewDulplicateBusterJobController(ApexPages.StandardController controller) {
selectedObject = 'account';
getObjectFields();
}
public Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
public String selectedObject {get; set;}
public SelectOption[] selectedFields { get; set; }
public SelectOption[] allFields { get; set; }
public String message { get; set; }
Public NewDulplicateBusterJobController(){
}
public List<SelectOption> getObjectNames(){
List<SelectOption> objNames = new List<SelectOption>();
for (Schema.SObjectType obj : schemaMap.values()){
Schema.DescribeSObjectResult describeSobject = obj.getDescribe();
String Name = describeSobject.getName();
String Label = describeSobject.getLabel();
if(Name == 'Account' || Name == 'Contact' || Name == 'Lead' || Name == 'Opportunity' || Name == 'Case' || Name == 'KnowledgeArticle' || describeSobject.isCustom()==true){
SelectOption so = new SelectOption( Name , Label );
objNames.add(so);
objNames.sort();
system.debug('--objNames--' +objNames);
List<SelectOption> allFields = getObjectFields();
}
}
return objNames;
}
public List<SelectOption> getObjectFields(){
selectedFields = new List<SelectOption>();
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType ObjectSchema = schemaMap.get(selectedObject);
Map<String, Schema.SObjectField> fieldMap = ObjectSchema.getDescribe().fields.getMap();
allFields = new List<SelectOption>();
for (String fieldName: fieldMap.keySet()) {
allFields.add(new SelectOption(fieldMap.get(fieldName).getDescribe().getName(),fieldMap.get(fieldName).getDescribe().getName()));
allFields.sort();
}
return allFields;
}
}
<apex:page standardController="Buster_Job__c" extensions="NewDulplicateBusterJobController" > <apex:form > <apex:pageBlock title="Duplicate Filter Edit"> <apex:pageblockButtons location="top"> <apex:commandButton value="Save" /> <apex:commandButton value="Save & Start" /> <apex:commandButton value="Cancel"/> </apex:pageblockButtons> <apex:pageBlockSection title="Filter Name" collapsible="false" columns="2"> <apex:pageBlockSectionItem > <apex:outputLabel value="Buster Job Name:"></apex:outputLabel> <apex:inputText title="Buster Job Name" value="{!BusterJobName}" required="true"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Select Standard or Custom Object" columns="2"> <apex:pageBlockSectionItem > <apex:outputlabel value="Object:"/> <apex:actionRegion > <apex:selectList value="{!selectedObject}" size="1"> <apex:selectOptions value="{!ObjectNames}"/> <apex:actionSupport event="onchange" rerender="myFields"/> </apex:selectList> </apex:actionRegion> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Select a Field and Its Rule"> <apex:pageblocksectionitem > <apex:outputPanel id="myFields"> <c:MultiselectPicklist leftLabel="Available Fields" leftOption="{!allFields}" rightLabel="Selected Fields" rightOption="{!selectedFields}" size="14" width="150px"/> </apex:outputpanel> </apex:pageblocksectionItem> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
For saving record, we have to specify action attribute for command button which will save our record. Standard apex controller contains a standard action '{!save}' . We can carry out an action for saving record using this standard action. You have to add an action attribute in command button in order to save a record as following:
Thanks
Banwari
Thanx
Thanks
Banwari