function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
niharnihar 

How to show URL field only stage(picklist) field 2 and 3 picklist options are selected on opportunity object


Hi  All,
I have created  picklist field with options(1,2,3,4) and url field in opportunity object..........
my requirment is when i choose 2 and 3 values in picklist the url field should be shown  and when i choose 1 or 4 values the url field must be disabled or not shown...........
How can i achieve these can anyone help me...................................

Thanks Inadvance..................
Best Answer chosen by nihar
Prashant Pandey07Prashant Pandey07
Hi Nihar,

If your opportunity is standard detail page then you can create two record type and pagelayout and in one-page layout show the url and another page don't show the url field. 
Create a workflow rule to update the record types based on picklist value.

https://success.salesforce.com/answers?id=90630000000hBX9AAM

If you have a visualforce page the the try render the url filed like this..
<apex:inputField value="{!Opportunity.URL__c}" rendered="{!Opportunity.Stage == '2'}" />

Let me know if you have any question.
--
Thanks,
Prashant

All Answers

Prashant Pandey07Prashant Pandey07
Hi Nihar,

If your opportunity is standard detail page then you can create two record type and pagelayout and in one-page layout show the url and another page don't show the url field. 
Create a workflow rule to update the record types based on picklist value.

https://success.salesforce.com/answers?id=90630000000hBX9AAM

If you have a visualforce page the the try render the url filed like this..
<apex:inputField value="{!Opportunity.URL__c}" rendered="{!Opportunity.Stage == '2'}" />

Let me know if you have any question.
--
Thanks,
Prashant
This was selected as the best answer
Narender Singh(Nads)Narender Singh(Nads)
Hi Nihar,

Use something like this:
<apex:outputtext value="YOUR_URL_HERE"  rendered="{!if(opportunity.custom_field_name__c=='2' || opportunity.custom_field_name__c=='3',true,false)}" />

let me know if it helps.
Thanks! 
Ajay K DubediAjay K Dubedi
Hi Nihar,

Please try the below code. Hope this will helps you.

<apex:page>
    <apex:form id="Form1">
        <apex:pageBlock id="theBlock">
            <apex:pageBlockSection id="thePageSection">
                <apex:selectList multiselect="false" size="1" id="theSelectList" onchange="showField();">
                    <apex:selectOption itemValue="0" itemLabel="None"/>
                    <apex:selectOption itemValue="1" itemLabel="One"/>
                    <apex:selectOption itemValue="2" itemLabel="Two"/>
                    <apex:selectOption itemValue="3" itemLabel="Three"/>
                    <apex:selectOption itemValue="4" itemLabel="Four"/>
                </apex:selectList>
            </apex:pageBlockSection>
            <apex:inputText id="thetext1" style="visibility:hidden;"/>
            <apex:inputText id="thetext2" style="visibility:hidden;"/>
        </apex:pageBlock>
    </apex:form>
    <Script>
        function showField()
        {
        var selectedvalue = document.getElementById('{!$Component.Form1:theBlock:thePageSection:theSelectList}').value;
        if(selectedvalue == '2' || selectedvalue == '3')
        {
        document.getElementById('{!$Component.Form1:theBlock:thetext1}').style.visibility='visible';
        document.getElementById('{!$Component.Form1:theBlock:thetext2}').style.visibility='visible';
        }
        if(selectedvalue == '1' || selectedvalue == '4')
        {
        document.getElementById('{!$Component.Form1:theBlock:thetext1}').style.visibility='hidden';
        document.getElementById('{!$Component.Form1:theBlock:thetext2}').style.visibility='hidden';
        }
        }
    </Script>
</apex:page>

Please mark it as best answer if you find it helpfull.

Thank You
Ajay Dubedi