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
balakrishna mandula 19balakrishna mandula 19 

Disabling picklist value from user lookup in visualforce page

Hi 
I am writing visualforce page in that I have Owner lookup field which is having lookup to Queue and User. If I select User then user values will be populated and if select Queue as pickilst Queues will be popoulated. 
My requirement is only Queue should be there in pickilist, not the User. 
Please help me in resolving this.

I used below javascript to hid User value.

function hid(){
            owner = "pageId:formId:pgBlckId:j_id84:6:j_id85:j_id86:0:j_id87_mlktp";
            var drop=document.getElementById(owner);
            drop.options[1].selected = true;
            drop.remove(0);
      }
        window.onload = hid;

with the above code I can hide the User value. Queue only is visible but user values are displaying not the Queue values.

please help me in resolving this
Rupal KumarRupal Kumar
Hi,
Use actionSupport on your picklist to rerender the container of your lookup field.  Something like this:
 
<apex:outputPanel id="thePanel">
 <apex:inputField value="{!myObject__c.myPicklist__c}">
 <apex:actionSupport event="onchange" action="{!doDisable}" rerender="thePanel"/>
 </apex:inputField> <apex:inputField value="{!myObject__c.myLookup__c}" rendered="{!shouldRender}"/> </apex:outputPanel>
 public void doDisable()
 { if (myObject__c.myPicklist__c == 'someValue') {
 shouldRender = false; 
} else 
{ shouldRender = true; } 
}


Thanks
Rupal Kumar
http://​mirketa.com
 





 
balakrishna mandula 19balakrishna mandula 19
Thanks Rupal Kumar for quick response.
I am not using <apex:inputField value="{!myObject__c.myPicklist__c}"> for the pagelayout. I am taking fields from fieldsets. That's why I used owner = "pageId:formId:pgBlckId:j_id84:6:j_id85:j_id86:0:j_id87_mlktp";
balakrishna mandula 19balakrishna mandula 19

User-added image

Owner is lookup field as Owner(User, Queue). I need to disable User from Owner. I am able to diable user value from picklist. when I am selecting value from look up user values only fetching not the Queue values.
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri
okasari ni code motham post cheyagalava ?
balakrishna mandula 19balakrishna mandula 19
Hi Vivek,


User-added image
Below is the code:
<apex:page showHeader="false" sidebar="false" standardController="Case" extensions="Extenstion" id="pageId">
<apex:form id="formId">
 <script>
  function hid(){
            owner = "pageId:formId:pgBlckId:j_id88:j_id89_mlktp";
            var drop=document.getElementById(owner);
            drop.options[1].selected = true;
            drop.remove(0);
   }
        window.onload = hid;
 </script>
 <apex:pageBlock title="New Task" id="pgBlckId">
<apex:pageBlockButtons >
    <apex:commandButton value="Save Task" action="{!saveTask}" status="actStatusId"/>
  <apex:pageBlockSection title="Assignment Details">
      <apex:inputField value="{!Task.OwnerId}"/>
      <apex:inputField value="{!Task.BMCServiceDesk__FKOpenBy__c}"/>
  </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

Controller:
global without sharing class Extension{
  public PageReference saveTask(){
   PageReference pageRef;
   Database.UpsertResult ur = Database.upsert(Task);
   pageRef = new PageReference('/apex/ABI_BSC_My_TaskPage');
   pageRef.setRedirect(True);
   return pageRef;
}