You need to sign in to do that
Don't have an account?
Mohammadasif Siddiqui
I am getting error
Unknown constructor 'HospitalController.HospitalController()'
Please help me
Unknown constructor 'HospitalController.HospitalController()'
<apex:page controller="HospitalController" > <apex:form > <apex:pageBlock > <apex:pageMessages id="showmsg"></apex:pageMessages> <apex:pageBlockSection > <apex:pageBlockSectionItem > Hospital Name : <apex:inputField value="{!hosp.Name}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > Account Name : <apex:inputField value="{!hosp.Account__c}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton action="{!insertNewItem}" value="Save" rerender="showmsg"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{! insertedrecord }" var="ct" id="mainSection"> <apex:column headerValue="Hospital Name">"{! ct.Name }"</apex:column> <apex:column headerValue="Account Name">"{! ct.Account__c }"</apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
public class HospitalController{ public Hospital__c hosp{get;set;} public Hospital__c insertedrecord{get;set;} public HospitalController( ApexPages.StandardController sc ) { this.hosp= (Hospital__c)sc.getRecord(); } public void insertNewItem() { if(hosp.Name == NULL || hosp.Name == '' ) { ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter Something')); } else { insert hosp; id insertedrecordid = hosp.Id; insertedrecord = [Select Name, Account__c from Hospital__c where Id = :insertedrecordid ]; hosp = new Hospital__c(); } } }
I am getting error
Unknown constructor 'HospitalController.HospitalController()'
Please help me
Greetings!
Can you please check the below document to get more details:
https://salesforce.stackexchange.com/questions/246207/extension-unknown-constructor
https://salesforce.stackexchange.com/questions/228744/unknown-constructor
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
This error might be because of the constructor in your apex class.If you are using your apex class as extension only then you have to pass ApexPages.StandardController as an argument to contructor.Please try by removing the argument from constructor.
Please refer below links which might help you in this
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_custom.htm
https://developer.salesforce.com/forums/?id=906F0000000AozUIAS
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards