You need to sign in to do that
Don't have an account?
saikrishna.G
VF Page:
<apex:page standardController="Order" extensions="O2I_OrderTest">
<apex:form >
<apex:sectionHeader title="New order" />
<apex:pageBlock title=" Order Edit" mode="Edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="cancel"/>
<!-- Calling controller actions by using action function when account and contacts are selected / changed -->
<apex:actionFunction name="Selectcon" action="{!Selectcon}" reRender="PreparedForBlock"/>
<apex:actionFunction name="Selectacc" action="{!Selectacc}" reRender="Addressblock"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information">
<apex:inputField value="{!ord.QuoteId}"/>
<apex:outputlabel > <b>Owner</b> {!$User.FirstName} {!$user.Lastname}</apex:outputlabel>
<apex:inputField value="{!ord.Opportunityid}"/>
<apex:inputField value="{!ord.O2I_So_Delivery_Date__c}"/>
<apex:inputField value="{!ord.Accountid}" required="true" onchange="Selectcon()" />
<apex:inputField value="{!ord.Status}"/>
<apex:inputField value="{!ord.ContractId}" required="true"/>
<apex:inputField value="{!ord.O2I_So_Order_to_Invoices_settings__c}" required="true"/>
<apex:inputField value="{!ord.PoNumber}"/>
<apex:inputField value="{!ord.EffectiveDate}"/>
<apex:inputField value="{!ord.Description}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Prepared For" id="PreparedForBlock">
<apex:inputField value="{!ord.CustomerAuthorizedByid}" onchange="Selectcon()"/>
<apex:inputField value="{!ord.O2I_So_phone__c}"/>
<apex:inputField value="{!ord.O2I_So_email__c}"/>
<apex:inputField value="{!ord.O2I_Fax__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Terms" columns="1">
<apex:inputField value="{!ord.O2I_Terms_and_Conditions__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Address" id="Addressblock">
<apex:inputField value="{!ord.O2I_So_Bill_To_Name__c}"/>
<apex:inputField value="{!ord.O2I_Ship_To_Name__c}"/>
<apex:inputField value="{!ord.BillingStreet }"/>
<apex:inputField value="{!ord.ShippingStreet}"/>
<apex:inputField value="{!ord.BillingCity}"/>
<apex:inputField value="{!ord.ShippingCity}"/>
<apex:inputField value="{!ord.BillingState}"/>
<apex:inputField value="{!ord.ShippingState}"/>
<apex:inputField value="{!ord.BillingpostalCode}"/>
<apex:inputField value="{!ord.ShippingpostalCode}"/>
<apex:inputField value="{!ord.BillingCountry}"/>
<apex:inputField value="{!ord.ShippingCountry}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex cllass:
public with sharing class O2I_OrderTest {
Public Order ord{Get;set;}
Public list<Order> ordr{Get;set;}
O2I_Order_to_Invoices_settings__c o2i;
public list<SelectOption> ChooseCurrency{get;set;}
public String selectedCurrency{get;set;}
Apexpages.StandardController scon;
Account acc;
Contact con;
public O2I_OrderTest(ApexPages.StandardController controller) {
this.ord=(Order)Controller.getRecord();
scon=controller;
string curr;
if(Userinfo.isMultiCurrencyOrganization() || system.test.isRunningTest()){
if(!system.test.isRunningTest())curr=String.valueof(ord.get('CurrencyIsoCode'));
ChooseCurrency = new List<SelectOption>();
chooseCurrency.add(new SelectOption(Userinfo.getDefaultCurrency(),Userinfo.getDefaultCurrency()));
Schema.sObjectType sobject_type = Account.getSObjectType(); //grab the sobject that was passed
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); //describe the sobject
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = (!system.test.isRunningTest())? field_map.get('CurrencyISoCode').getDescribe().getPickListValues() : Account.Type.getDescribe().getPicklistValues(); //grab the list of picklist values for the passed field on the sobject
for (Schema.PicklistEntry a : pick_list_values) { //for all values in the picklist list
if(a.getValue()!=Userinfo.getDefaultCurrency())
ChooseCurrency.add(new SelectOption(a.getValue(),a.getlabel()));//add the value to our final list
}
}
}
Public pagereference Selectacc(){
if(Ord.AccountId!=null){
acc=[Select Name,BillingStreet,BillingCity,BillingState,Billingpostalcode,billingCountry,Shippingstreet,Shippingcity,shippingstate,shippingpostalcode,shippingcountry from Account where id=:Ord.AccountId];
ord.O2I_So_Bill_To_Name__c=acc.name;
ord.BillingStreet=acc.BillingStreet;
ord.BillingCity=acc.BillingCity;
ord.BillingState=acc.BillingState;
//ord..Billingpostalcode=acc.Billingpostalcode;
ord.billingCountry=acc.billingCountry;
ord.O2I_Ship_To_Name__c=acc.name;
ord.Shippingstreet=acc.Shippingstreet;
ord.Shippingcity=acc.Shippingcity;
ord.shippingstate=acc.shippingstate;
ord.shippingpostalcode=acc.shippingpostalcode;
ord.shippingcountry=acc.shippingcountry;
}
return null;
}
Public pagereference Selectcon(){
if(ord.CustomerAuthorizedByid!=null){
con=[Select Email,Phone,Fax from Contact where id=:ord.CustomerAuthorizedByid];
ord.O2I_So_phone__c=con.phone;
ord.O2I_So_email__c=con.email;
ord.O2I_Fax__c=con.fax;
}
return null;
}
}
Standard save functionality is not working when i am trying to create a visual force page on order object
VF Page:
<apex:page standardController="Order" extensions="O2I_OrderTest">
<apex:form >
<apex:sectionHeader title="New order" />
<apex:pageBlock title=" Order Edit" mode="Edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
<apex:commandButton action="{!cancel}" value="cancel"/>
<!-- Calling controller actions by using action function when account and contacts are selected / changed -->
<apex:actionFunction name="Selectcon" action="{!Selectcon}" reRender="PreparedForBlock"/>
<apex:actionFunction name="Selectacc" action="{!Selectacc}" reRender="Addressblock"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information">
<apex:inputField value="{!ord.QuoteId}"/>
<apex:outputlabel > <b>Owner</b> {!$User.FirstName} {!$user.Lastname}</apex:outputlabel>
<apex:inputField value="{!ord.Opportunityid}"/>
<apex:inputField value="{!ord.O2I_So_Delivery_Date__c}"/>
<apex:inputField value="{!ord.Accountid}" required="true" onchange="Selectcon()" />
<apex:inputField value="{!ord.Status}"/>
<apex:inputField value="{!ord.ContractId}" required="true"/>
<apex:inputField value="{!ord.O2I_So_Order_to_Invoices_settings__c}" required="true"/>
<apex:inputField value="{!ord.PoNumber}"/>
<apex:inputField value="{!ord.EffectiveDate}"/>
<apex:inputField value="{!ord.Description}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Prepared For" id="PreparedForBlock">
<apex:inputField value="{!ord.CustomerAuthorizedByid}" onchange="Selectcon()"/>
<apex:inputField value="{!ord.O2I_So_phone__c}"/>
<apex:inputField value="{!ord.O2I_So_email__c}"/>
<apex:inputField value="{!ord.O2I_Fax__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Terms" columns="1">
<apex:inputField value="{!ord.O2I_Terms_and_Conditions__c}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Address" id="Addressblock">
<apex:inputField value="{!ord.O2I_So_Bill_To_Name__c}"/>
<apex:inputField value="{!ord.O2I_Ship_To_Name__c}"/>
<apex:inputField value="{!ord.BillingStreet }"/>
<apex:inputField value="{!ord.ShippingStreet}"/>
<apex:inputField value="{!ord.BillingCity}"/>
<apex:inputField value="{!ord.ShippingCity}"/>
<apex:inputField value="{!ord.BillingState}"/>
<apex:inputField value="{!ord.ShippingState}"/>
<apex:inputField value="{!ord.BillingpostalCode}"/>
<apex:inputField value="{!ord.ShippingpostalCode}"/>
<apex:inputField value="{!ord.BillingCountry}"/>
<apex:inputField value="{!ord.ShippingCountry}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
apex cllass:
public with sharing class O2I_OrderTest {
Public Order ord{Get;set;}
Public list<Order> ordr{Get;set;}
O2I_Order_to_Invoices_settings__c o2i;
public list<SelectOption> ChooseCurrency{get;set;}
public String selectedCurrency{get;set;}
Apexpages.StandardController scon;
Account acc;
Contact con;
public O2I_OrderTest(ApexPages.StandardController controller) {
this.ord=(Order)Controller.getRecord();
scon=controller;
string curr;
if(Userinfo.isMultiCurrencyOrganization() || system.test.isRunningTest()){
if(!system.test.isRunningTest())curr=String.valueof(ord.get('CurrencyIsoCode'));
ChooseCurrency = new List<SelectOption>();
chooseCurrency.add(new SelectOption(Userinfo.getDefaultCurrency(),Userinfo.getDefaultCurrency()));
Schema.sObjectType sobject_type = Account.getSObjectType(); //grab the sobject that was passed
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe(); //describe the sobject
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = (!system.test.isRunningTest())? field_map.get('CurrencyISoCode').getDescribe().getPickListValues() : Account.Type.getDescribe().getPicklistValues(); //grab the list of picklist values for the passed field on the sobject
for (Schema.PicklistEntry a : pick_list_values) { //for all values in the picklist list
if(a.getValue()!=Userinfo.getDefaultCurrency())
ChooseCurrency.add(new SelectOption(a.getValue(),a.getlabel()));//add the value to our final list
}
}
}
Public pagereference Selectacc(){
if(Ord.AccountId!=null){
acc=[Select Name,BillingStreet,BillingCity,BillingState,Billingpostalcode,billingCountry,Shippingstreet,Shippingcity,shippingstate,shippingpostalcode,shippingcountry from Account where id=:Ord.AccountId];
ord.O2I_So_Bill_To_Name__c=acc.name;
ord.BillingStreet=acc.BillingStreet;
ord.BillingCity=acc.BillingCity;
ord.BillingState=acc.BillingState;
//ord..Billingpostalcode=acc.Billingpostalcode;
ord.billingCountry=acc.billingCountry;
ord.O2I_Ship_To_Name__c=acc.name;
ord.Shippingstreet=acc.Shippingstreet;
ord.Shippingcity=acc.Shippingcity;
ord.shippingstate=acc.shippingstate;
ord.shippingpostalcode=acc.shippingpostalcode;
ord.shippingcountry=acc.shippingcountry;
}
return null;
}
Public pagereference Selectcon(){
if(ord.CustomerAuthorizedByid!=null){
con=[Select Email,Phone,Fax from Contact where id=:ord.CustomerAuthorizedByid];
ord.O2I_So_phone__c=con.phone;
ord.O2I_So_email__c=con.email;
ord.O2I_Fax__c=con.fax;
}
return null;
}
}
1.Put <apex:pageMessages> in your visualforce page and see what is happening.
2. Check debug log after the button is pressed.
3. The reason might be some of the validation rule errors or invalid value might cause the problem.