You need to sign in to do that
Don't have an account?
lekkala malyadri 8
Custom Logic
Hi how to implement a custom save logic using standard controller on a custom sobject
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
As you want to implement a custom save logic on a custom object please follow the below code snippet.
VF Page:
<apex:page standardController="faculty__c" extensions="CustomSaveLogic">
{!greeting} <p/>
<apex:form >
<apex:pageBlock title="Using standard controller implementing a custom save logic" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!faculty__c.name}"/> <p/>
<apex:inputField value="{!faculty__c.Salary__c}"/> <p/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Page :
public class CustomSaveLogic {
private final Faculty__c fct;
// The extension constructor initializes the private member
// variable fct by using the getRecord method from the standard
// controller.
public CustomSaveLogic(ApexPages.StandardController fctController) {
this.fct = (faculty__c)fctController.getRecord();
}
public String getGreeting() {
return 'Hello nagendra' + fct.name + ' (' + fct.id + ')';
}
}
Mark it as solved if it helps you.
Thanks & Regards,
Nagendra.P
All Answers
As you want to implement a custom save logic on a custom object please follow the below code snippet.
VF Page:
<apex:page standardController="faculty__c" extensions="CustomSaveLogic">
{!greeting} <p/>
<apex:form >
<apex:pageBlock title="Using standard controller implementing a custom save logic" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!faculty__c.name}"/> <p/>
<apex:inputField value="{!faculty__c.Salary__c}"/> <p/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Page :
public class CustomSaveLogic {
private final Faculty__c fct;
// The extension constructor initializes the private member
// variable fct by using the getRecord method from the standard
// controller.
public CustomSaveLogic(ApexPages.StandardController fctController) {
this.fct = (faculty__c)fctController.getRecord();
}
public String getGreeting() {
return 'Hello nagendra' + fct.name + ' (' + fct.id + ')';
}
}
Mark it as solved if it helps you.
Thanks & Regards,
Nagendra.P
Reference following code :
VF -
----------------------------------
Controller -
----------------------------------
Regards,
Amritesh