The requirement is On the std layout of opportunity,there is a field probability which has some default value based on the stage that you use. When I modify the default value of probability,I have to display a Waring message on screen. e.g.At Initial Stage Probability Value is 10% i have to change it 15%.As soon as I change to 15%,it should display some warning message which will display via inline VF.
for this I have written below code:
public static void probabilityDefaultValueChange(List<Opportunity>opt,Map<Id,Opportunity> optt)
{
List<Id>oppIds=new List<Id>();
for(Opportunity o:opt)
{
if(o.Probability!=null && o.Id!=null && optt.get(o.Id).Probability!=10 )
{
oppIds.add(o.Id);
}
}
List<Opportunity>opToUpdate=[Select Id,StageName,Probability,Custom_Probability_Change__c from Opportunity where Id in:oppIds];
for(Opportunity o1:opToUpdate)
{
o1.Custom_Probability_Change__c=true;
}
Update opToUpdate;
}
Custom_Probability_Change__c is a checkbox field That I have to send it Inline VF in order to display warning message and the condition optt.get(o.Id).Probability!=10 it checks whether Probability default value is default(10% here) or not.If i change default value(10%) to 15% it should update Custom_Probability_Change__c checkbox field to true.But it is not updating checkbox field value.
Can someone please guide what I am missing in this code?
Also I am new to VF page and not sure how to pass the Field value to VF page to display warning message(In this case I will send Custom_Probability_Change__ value to VF and once it checkbox field value is true,it displays warning message).It would be great if someone can help me with that.