You need to sign in to do that
Don't have an account?
sfdc@isha.ax1814
Display error message when we select the picklist value in vfpage
Hi Team,
I want to display error mesg when we select 'Other-Explain'.
<apex:page showHeader="false" action="{!InitMethod}" cache="false" controller="AH_HN_PhysicianAcceptnReject_CLS" tabStyle="Case">
<apex:includeScript value="/soap/ajax/36.0/connection.js"/>
<apex:includeScript value="/soap/ajax/36.0/apex.js"/>
<apex:includeLightning />
<apex:Pagemessages />
<head>
<apex:slds />
<div class="slds-align_absolute-center">
<apex:image url="{!$Resource.AH_Physician_Expert_Template_Logo}" />
</div>
</head>
<apex:form >
<div class="slds-align_absolute-center">
<apex:outputText rendered="{!ThanksmsgAccpt}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for accepting, the case has now been added to your dashboard. Please log into the physician portal to begin your review.</span>
</apex:outputText>
<!--
<apex:outputText rendered="{!ThanksmsgRejec}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/> </span>
</apex:outputText>
-->
<apex:outputText rendered="true">
<apex:pageBlock >
<!-- span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/><br/> </span -->
<p>Please select the reason:</p>
<apex:actionRegion >
<apex:selectList id="Pleaseselectthereason" size="1" label="caseRejectReason" value="{!caseRejectReason}">
<apex:selectoption itemLabel="Out of office-cannot complete due to existing workload" itemValue="Out of office-cannot complete due to existing workload"></apex:selectoption>
<apex:selectoption itemLabel="I recommend another physician more suitable for this case.Enter Name in Free Text Box" itemValue="I recommend another physician more suitable for this case.Enter Name in Free Text Box"></apex:selectoption>
<apex:selectoption itemLabel="Other - explain" itemValue="Other - explain"></apex:selectoption>
<!--<apex:actionSupport event="onchange" reRender="comments" />-->
</apex:selectList>
</apex:actionRegion>
<br/>
<p>Comments:</p>
<apex:inputTextarea label="Comments" style="width:550px;height:100px" id="comments" value="{!caseRejectComment}"/>
<br/><br/>
<div align="center" draggable="false" >
<apex:commandButton action="{!saveRejectInfo}" value="Save"/>
</div>
</apex:pageBlock>
</apex:outputText>
<apex:outputText rendered="{!rejectreasonmessage}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.</span>
</apex:outputText>
<apex:outputText rendered="{!Assignedtoothers}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">This case has already been assigned to some other physician.</span>
</apex:outputText>
<apex:outputText rendered="{!AlreadyAccepted}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already accepted the case.</span>
</apex:outputText>
<apex:outputText rendered="{!AlreadyRejected}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already rejected the case.</span>
</apex:outputText>
</div>
</apex:form>
</apex:page>
Regards,
Isha
I want to display error mesg when we select 'Other-Explain'.
<apex:page showHeader="false" action="{!InitMethod}" cache="false" controller="AH_HN_PhysicianAcceptnReject_CLS" tabStyle="Case">
<apex:includeScript value="/soap/ajax/36.0/connection.js"/>
<apex:includeScript value="/soap/ajax/36.0/apex.js"/>
<apex:includeLightning />
<apex:Pagemessages />
<head>
<apex:slds />
<div class="slds-align_absolute-center">
<apex:image url="{!$Resource.AH_Physician_Expert_Template_Logo}" />
</div>
</head>
<apex:form >
<div class="slds-align_absolute-center">
<apex:outputText rendered="{!ThanksmsgAccpt}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for accepting, the case has now been added to your dashboard. Please log into the physician portal to begin your review.</span>
</apex:outputText>
<!--
<apex:outputText rendered="{!ThanksmsgRejec}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/> </span>
</apex:outputText>
-->
<apex:outputText rendered="true">
<apex:pageBlock >
<!-- span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.<br/><br/> </span -->
<p>Please select the reason:</p>
<apex:actionRegion >
<apex:selectList id="Pleaseselectthereason" size="1" label="caseRejectReason" value="{!caseRejectReason}">
<apex:selectoption itemLabel="Out of office-cannot complete due to existing workload" itemValue="Out of office-cannot complete due to existing workload"></apex:selectoption>
<apex:selectoption itemLabel="I recommend another physician more suitable for this case.Enter Name in Free Text Box" itemValue="I recommend another physician more suitable for this case.Enter Name in Free Text Box"></apex:selectoption>
<apex:selectoption itemLabel="Other - explain" itemValue="Other - explain"></apex:selectoption>
<!--<apex:actionSupport event="onchange" reRender="comments" />-->
</apex:selectList>
</apex:actionRegion>
<br/>
<p>Comments:</p>
<apex:inputTextarea label="Comments" style="width:550px;height:100px" id="comments" value="{!caseRejectComment}"/>
<br/><br/>
<div align="center" draggable="false" >
<apex:commandButton action="{!saveRejectInfo}" value="Save"/>
</div>
</apex:pageBlock>
</apex:outputText>
<apex:outputText rendered="{!rejectreasonmessage}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">Thank you for rejecting the case.</span>
</apex:outputText>
<apex:outputText rendered="{!Assignedtoothers}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">This case has already been assigned to some other physician.</span>
</apex:outputText>
<apex:outputText rendered="{!AlreadyAccepted}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already accepted the case.</span>
</apex:outputText>
<apex:outputText rendered="{!AlreadyRejected}">
<span style="font-size:20px;font-weight:bold;" class="slds-m-top_xx-large">You have already rejected the case.</span>
</apex:outputText>
</div>
</apex:form>
</apex:page>
Regards,
Isha
.
and bind it to the select list on change.
After changes with minor tweaks
Your final output be the below. Hope this help!
All Answers
I think it could be implemented two ways :
1. Add validation in controller method which is getting called on "Save" button click which should add message to VF page if "Other-Explain" picklist value was selected. OR
2. Create Javascript method and use it in onchange event on picklist to display error if "Other-Explain" is picklist value.
Thanks
Please find below controller and i tried but it is not working. can you please help me with the code.
public class AH_HN_PhysicianAcceptnReject_CLS {
public boolean ThanksmsgAccpt{get;set;}
public boolean ThanksmsgRejec{get;set;}
public boolean AlreadyAccepted{get;set;}
public boolean AlreadyRejected{get;set;}
public boolean Assignedtoothers{get;set;}
public boolean rejectreason{get;set;}
public boolean rejectreasonmessage{get;set;}
public string caseRejectReason{get;set;}
public string caseRejectComment{get;set;}
Public void Initmethod(){
ThanksmsgAccpt=false;
ThanksmsgRejec=false;
Assignedtoothers=false;
AlreadyAccepted = false;
AlreadyRejected=false;
Id id = apexpages.currentpage().getparameters().get('id');
String Physician = apexpages.currentpage().getparameters().get('Physician');
string Action = apexpages.currentpage().getparameters().get('Accept');
system.debug('Id:::::::'+id);
system.debug('Physician:::::'+Physician);
system.debug('Action::::::'+Action);
if(id != null){
Assigned_Physician__c AP= [select id,Current_Physician__c,Physician_1_Activity__c,Physician_2_Activity__c,Physician_3_Activity__c,No_Physicians_in_Queue__c from Assigned_Physician__c where id=:id];
if(AP.Current_Physician__c == 'Physician1' && Action == 'True' && AP.Current_Physician__c == Physician && AP.No_Physicians_in_Queue__c==false){
if(AP.Physician_1_Activity__c =='Accepted'){
AlreadyAccepted = true;
}
if(AP.Physician_1_Activity__c =='Rejected'){
AlreadyRejected = true;
}
if(AP.Physician_1_Activity__c !='Accepted' && AP.Physician_1_Activity__c !='Rejected'){
AP.Physician_1_Activity__c = 'Accepted';
ThanksmsgAccpt=true;
Update AP;
}
}
if(AP.Current_Physician__c == 'Physician1' && Action == 'False' && AP.Current_Physician__c == Physician && AP.No_Physicians_in_Queue__c==false){
if(AP.Physician_1_Activity__c =='Rejected' ){
AlreadyRejected = true;
}
if(AP.Physician_1_Activity__c =='Accepted'){
AlreadyAccepted = true;
}
//@Ranjit Modified 28/Jan/21
if(AP.Physician_1_Activity__c !='Accepted' && AP.Physician_1_Activity__c !='Rejected'){
ThanksmsgRejec=true;
}
}
Public void saveRejectInfo(){
System.debug('Inside saveRejectInfo');
Id id = apexpages.currentpage().getparameters().get('id');
String Physician = apexpages.currentpage().getparameters().get('Physician');
string Action = apexpages.currentpage().getparameters().get('Accept');
Assigned_Physician__c AP= [select id,Current_Physician__c,Physician_1_Activity__c,Physician_2_Activity__c,Physician_3_Activity__c,No_Physicians_in_Queue__c from Assigned_Physician__c where id=:id];
//Physician-1
if(AP.Current_Physician__c == 'Physician1' && Action == 'False' && AP.Current_Physician__c == Physician && AP.No_Physicians_in_Queue__c==false){
if(AP.Physician_1_Activity__c !='Accepted' && AP.Physician_1_Activity__c !='Rejected'){
if(caseRejectReason == 'Other - explain' && caseRejectComment == null){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'Please enter value'));
//return null;
system.debug('Inside 007');
}
else{
system.debug('Inside 008');
AP.Physician_1_Activity__c = 'Rejected';
AP.Physician_1_Reason_for_reject__c = caseRejectReason;
AP.Physician_1_Reject_Comments__c = caseRejectComment;
Update AP;
ThanksmsgRejec=false;
rejectreasonmessage = true;
}
}
}
//Physician-2
}
}
Regards,
Isha
.
and bind it to the select list on change.
After changes with minor tweaks
Your final output be the below. Hope this help!
Thank you somuch for your help.
when the picklist value is 'Other-explain' comments should not be blank.
Now error is showing up in vfpage but i am able to save the record with out comments notes. Can you please help me out on this issue.
Regards,
Isha
You need to just make the minor adjustment in your saveRejectInfo method
Below is the code after some adjustment
Try out with this one.
Thank you somuch for your quick help.
Regards,
Isha