You need to sign in to do that
Don't have an account?
mnz123
ActionFunction to create an account?
I'm trying to create an account using actionFunction and display the result in the same page. I have tried successfully the "sayHello" example in http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm . But it's not helping me to build this application. Can anyone guide me through this? Any reference would be helpful. Thanks
I don't understand what that exactly mean.
Are you asking to create person account?
Controller code (partial):
Account acct;
public String salutation {get; set;}
public String fname{get; set;}
public String lname{get; set;}
public PageReference save() {
try {
// check for person account record type
recType = [select id,name,sobjectType,ispersontype from recordType where ispersontype=true and sobjectType='account' limit 1];
if(acct.recordtypeid == recType.id) {
acct.Salutation=salutation;
acct.FirstName=fname;
acct.LastName=lname;
insert(acct);
PageReference newPage = New PageReference('/'+acct.id);
newPage.setRedirect(true);
return newPage;
}
else {
insert(acct);
PageReference newPage = New PageReference('/'+acct.id);
newPage.setRedirect(true);
return newPage;
}
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
return null;
}
Visualforce code (partial):
<apex:pageblocksectionitem >
<apex:outputlabel value="First Name"/>
<apex:outputpanel >
<apex:inputText value="{!salutation}" id="personSalutation"/>
<apex:inputText value="{!fname}" id="personFname"/>
</apex:outputpanel>
</apex:pageblocksectionitem>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Last Name" for="personLname"></apex:outputLabel>
<apex:inputText value="{!lname}" id="personLname"/>
</apex:pageBlockSectionItem>
Hope it helps.
Please refer this link to understand about apex:actionFunction
http://www.salesforceworld.blogspot.co.uk/2011/06/parameter-passing-using.html
http://www.cloudforce4u.com/2013/09/passing-parameters-in-action-function.html
Thanks
Vikash_SFDC