Visualforce Page:
<apex:page controller="Customcls">
<apex:form>
<apex:pageblock>
<apex:pageblocksection>
Name:<apex:inputtext value="{!name}"/>
Phone:<apex:inputtext value="{!phone}"/>
<apex:commandbutton value="Show Record" action="{!show}"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex class:
global with sharing class Customcls implements Schedulable {
global void execute(SchedulableContext sc){
Customcls obj= new Customcls ();
}
public Customcls(){
show1();
}
public Customcls(ApexPages.StandardController controller) {
}
public void show1(){
System.debug('-------->This method is called from schedule APex');
}
public String phone { get; set; }
public PageReference show() {
System.debug('-------'+name);
System.debug('-------'+phone);
Account obj = new Account();
obj.Name = name;
obj.Phone = phone;
System.debug('--------'+obj.id);
insert obj;
System.debug('--------'+obj.id);
Contact c = new Contact();
c.lastname = name;
c.Phone = phone;
c.accountid=obj.id;
insert c;
pagereference ref= new pagereference('/'+obj.Id);
return ref;
}
public string name{get; set;}
}
No comments:
Post a Comment