You need to sign in to do that
Don't have an account?
Ab
Display of error messages on screen(VF) when pcklist is changed
Hello,
I have a VF, conroller and the page display like below:
Problem:
1) once if the error message is displyed on screen, then until the "accccount id " is filled, no "action" is executed.
For example, in my use case action "updateSubjectAndDescription" is never executed if a error message is added to screen.
2) similar case happens when Asset become mandatory
3) the issue occurs when "Type" is changed or "save" is clicked.
Questions:
1) I perfectly understad that, when "save" is cliked then erro message should be displyed, but i do not understad why error mesage is displyed when "Type" is changed.
thanks for suggestions
I have a VF, conroller and the page display like below:
<apex:page standardController="Case" extensions="Controller_Extension_Class" > <script type="text/javascript" language="javascript"> function callJS(id1) { var v1 =''; if(document.getElementById(id1) != null){ v1 = document.getElementById(id1).value; } callAF(v1); } </script> <apex:sectionHeader title="Case Edit" subtitle="New Case"/> <apex:form > <apex:pageMessages id="IdOfErrorMessages" /> <apex:actionFunction name="callAF" action="{!updateSubjectAndDescription}" reRender="IdOfAsset,IdOfType, IdOfSubject,IdOfDescription, IdOfErrorMessages"> <apex:param name="AssetValue" value="" /> <apex:param name="profileName" value="{!$Profile.Name}" /> </apex:actionFunction> <apex:pageBlock title="Case Edit" mode="detail"> <apex:pageBlockButtons location="bottom"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Case Information" columns="2" > <apex:inputField value="{!caseObj.CaseNumber}" /> <apex:inputField value="{!caseObj.AccountId}" required="true"/> <apex:inputField value="{!caseObj.Status}" required="true"/> <apex:inputField id="IdOfAsset" value="{!caseObj.AssetId}" required="{!IsRequired}" rendered="{!IsRendered}" /> <apex:pageBlockSectionItem /> </apex:pageBlockSection> <apex:pageBlockSection title="Description Information" columns="1"> <apex:inputField id="IdOfType" value="{!caseObj.Type}" required="true" onchange="callJS('{!$Component.IdOfType}');" /> <apex:inputField id="IdOfSubject" value="{!caseObj.Subject}" /> <apex:inputField id="IdOfDescription" value="{!caseObj.Description}" /> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public with sharing class Controller_Extension_Class { public Case caseObj {get;set;} public boolean IsRequired {get; set;} public boolean IsRendered {get; set;} public Controller_Extension_Class(ApexPages.StandardController controller){ caseObj = (Case)controller.getRecord(); IsRequired = false; IsRendered = true; } public void updateSubjectAndDescription(){ String selectedType = System.currentPageReference().getParameters().get('AssetValue'); String profileOfUser = System.currentPageReference().getParameters().get('profileName'); IsRequired = false; IsRendered = true; if(profileOfUser == 'XYZ'){ if(selectedType == 'Pick Val1'){ IsRequired = true; }else if(selectedType == 'Pick Val2'){ IsRendered = false; } } }
Problem:
1) once if the error message is displyed on screen, then until the "accccount id " is filled, no "action" is executed.
For example, in my use case action "updateSubjectAndDescription" is never executed if a error message is added to screen.
2) similar case happens when Asset become mandatory
3) the issue occurs when "Type" is changed or "save" is clicked.
Questions:
1) I perfectly understad that, when "save" is cliked then erro message should be displyed, but i do not understad why error mesage is displyed when "Type" is changed.
thanks for suggestions
Hi Sandrine,
You have to remove required="true" atribute on Account Id Field, you have to add this attribute styleClass="brdr"
<style>
.brdr {
border-left: 2px solid red;
}
</style>
Next you have to create standard validation rule for AccountId Or you have to write error msg logic on save method.
I think it will helps to you, In case you are geeting any issue please reach me out.
Thanks,
raghavendra Reddy.D
All Answers
This is beacuse you have added this line in VF page for Type field -
onchange="callJS('{!$Component.IdOfType}');
If you don't want this then remove onchange attribute.
Thanks
Saurabh
Hi Sandrine,
If not required, please remove onChange property on Type Field, else you need to use Action Region for the components which need to be processed by server. So that you will be not that error on change of Type value.
hope it helps
Thanks
Brahma
i am obliged to use above line.
I have tried to add action region but it also gives the same results
Hi Sandrine,
You have to remove required="true" atribute on Account Id Field, you have to add this attribute styleClass="brdr"
<style>
.brdr {
border-left: 2px solid red;
}
</style>
Next you have to create standard validation rule for AccountId Or you have to write error msg logic on save method.
I think it will helps to you, In case you are geeting any issue please reach me out.
Thanks,
raghavendra Reddy.D