You need to sign in to do that
Don't have an account?
PS81
Picklist event : ActionSupport doesn't work
Hi
I have a picklist in my VF page and have set an event.....based on the value that is picked i need to set a percentage field with some value which i think is not happeing....i'm sure there is something i'm missing and need help to fix it please?
my vf code:
<apex:inputfield value="{!Opportunity.StageName}" >
<apex:actionSupport id="oprstage" event="onchange" action="{!setProbability}" rerender="productInfo" immediate="TRUE" />
</apex:inputfield>
<apex:inputfield value="{!Opportunity.Day_Rate__c}" id="oprrate"/>
<apex:inputfield value="{!opr.Probability}" id="oprprob"/>
controller:
public with sharing class OpportunitySave {
public string probability {get;set;}
public Opportunity opr {get;set;}
public OpportunitySave(ApexPages.StandardController controller) {
}
public PageReference setProbability(){
opr.Probability = '30%';
return null;
}
}
I have a picklist in my VF page and have set an event.....based on the value that is picked i need to set a percentage field with some value which i think is not happeing....i'm sure there is something i'm missing and need help to fix it please?
my vf code:
<apex:inputfield value="{!Opportunity.StageName}" >
<apex:actionSupport id="oprstage" event="onchange" action="{!setProbability}" rerender="productInfo" immediate="TRUE" />
</apex:inputfield>
<apex:inputfield value="{!Opportunity.Day_Rate__c}" id="oprrate"/>
<apex:inputfield value="{!opr.Probability}" id="oprprob"/>
controller:
public with sharing class OpportunitySave {
public string probability {get;set;}
public Opportunity opr {get;set;}
public OpportunitySave(ApexPages.StandardController controller) {
}
public PageReference setProbability(){
opr.Probability = '30%';
return null;
}
}
All Answers
Remove immediate="TRUE" attribute in actionsupport and rerender the correct block id. If not this works, share your code.
You can have a below example, this will give you a clear thought.
http://www.cloudforce4u.com/2013/07/render-and-rerender-in-salesforce.html
System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!setProbability}' in page opportunitysave: Class.OpportunitySave.setProbability: line 8, column 1
Class.OpportunitySave.setProbability: line 8, column 1
public with sharing class OpportunitySave {
public string probability {get;set;}
public Opportunity opr {get;set;}
public OpportunitySave(ApexPages.StandardController controller) {
}
public PageReference setProbability(){
Opportunity.Probability = 30;
return null;
}
}
VF page:
<apex:page standardController="Opportunity" tabStyle="Opportunity" extensions="OpportunitySave" >
<apex:form >
<body>
<apex:pageBlock title="Opportunity Edit" mode="edit" >
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!Cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageblocksection id="OprInfo" title="Opportunity Information" columns="2">
<apex:inputfield value="{!Opportunity.name}" id="oprname"/>
<apex:inputfield value="{!Opportunity.AccountId}" id="opraccname"/>
<apex:inputfield value="{!Opportunity.Business__c}" id="oprbusiness"/>
<apex:outputfield value="{!Opportunity.OwnerId}" id="oprOwner"/>
<apex:inputfield value="{!Opportunity.Area__c}" id="oprarea"/>
<apex:inputfield value="{!Opportunity.Opportunity_Team__c}" id="oprteam"/>
<apex:inputfield value="{!Opportunity.New_Ext__c}" id="oprnewext"/>
<apex:inputfield value="{!Opportunity.Practice_Director__c}" id="oprpractdirect"/>
<apex:inputfield value="{!Opportunity.Type}" id="oprType"/>
<apex:inputfield value="{!Opportunity.CloseDate}" id="oprCloseDate"/>
<apex:inputfield value="{!Opportunity.Base_Location__c}" id="oprloc"/>
<apex:inputfield value="{!Opportunity.Start_Date__c}" id="oprsdate"/>
<apex:inputfield value="{!Opportunity.Presales__c}" id="oprpresales"/>
<apex:inputfield value="{!Opportunity.Number_of_Days__c}" id="oprndays"/>
<apex:inputfield value="{!Opportunity.StageName}" >
<apex:actionSupport id="oprstage" event="onchange" action="{!setProbability}" rerender="OprInfo" />
</apex:inputfield>
<apex:inputfield value="{!Opportunity.Day_Rate__c}" id="oprrate"/>
<apex:inputfield value="{!Opportunity.Probability}" id="oprprob"/>
<apex:inputfield value="{!Opportunity.CampaignId}" id="oprcamp"/>
<apex:inputfield value="{!Opportunity.Closed_Lost__c}" id="oprcloselot"/>
<apex:outputText ></apex:outputText>
<apex:inputfield value="{!Opportunity.Reason_for_Lost__c}" id="oprlostreason" style="width:250px ; height:100px"/>
</apex:pageblocksection>
</apex:pageBlock>
</body>
</apex:form>
</apex:page>
Here is the updated code,
VF:
class: