You need to sign in to do that
Don't have an account?
Tarun Kaushik
How to make a field mendatory when a field(picklist) on the same object change.
Hi All
I have two field on same object
1 -status(picklist values-opened,pending,resolved,closed)
2 -notes
If status="pending" then notes field should become mendetory on the spot without any other action,just an update on status field.
or
if status="closed" then some other fields should become mendatory on the spot
I have two field on same object
1 -status(picklist values-opened,pending,resolved,closed)
2 -notes
If status="pending" then notes field should become mendetory on the spot without any other action,just an update on status field.
or
if status="closed" then some other fields should become mendatory on the spot
2) use, Visualforce Ajax Support to rerender the section with the fields required. basically you have to use apex:actionRegion and apex:actionSupport
Below is the sample, you can refer, it is a template, you have replace <object> etc.
<apex:outputPanel id="MyPanel">
<apex:actionRegion >
<apex:pageblockSectionItem > <apex:outputLabel value="{!$ObjectType.<object>.Fields.<picklistfield>.label}" /><apex:inputField required="true" value="{!<object>.<picklistfield>}"><apex:actionSupport event="onchange" rerender="MyPanel" oncomplete="setDefaultCountry()"/></apex:inputField> </apex:pageblockSectionItem>
<apex:pageblockSectionItem required="{!IF(<object>.<picklistfield> = 'pending', true, false)}"> <apex:outputLabel value="{!$ObjectType.<object>.Fields.<otherfield>.label}" /> <apex:inputField id="opportunity" required="true" value="{!<object>.<otherfield>}"/> </apex:pageblockSectionItem>
</apex:actionRegion>
</apex:outputPanel>
Error Message for Validation Rule:
OR
(
ISPICKVAL(Status, "pending")
&&
ISBLANK(Notes)
)
,
(
ISPICKVAL(Status, "Closed")
&&
ISBLANK(Some_other_field__c)
)
Don't forget to check that it's actually working as well, with both positive and negative tests