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
palak agarwalpalak agarwal 

Adding list view buttons on the basis of recordtype in enhanced list on visualforce page

Hi all,

 

I have created two visualforce tabs for contact, each showing records of two diferent record types i.e Contact and Job Seeker, using enhanced list.

I want add list view buttons such as new Contact and new job seeker on visualforce page, according to the recordtype.

Is it possible to do so. Please help me its urgent.

 

With Regards,

Palak Agarwal

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference :

 

------ vf page------------

<apex:page controller="cls_checkrecordtype" >

  <apex:form >

      <apex:commandButton value="new contact" rendered="{!IF(displaybt=true,'true','false')}"/>

      <apex:commandButton value="Job Seeker" rendered="{!IF(displaybt=true,'false','true')}" />

 

 

  </apex:form>

</apex:page>

 

------ Apex controller ---------------

 

public class cls_checkrecordtype

{

    public boolean displaybt{get;set;}

    public cls_checkrecordtype()

    {

        string conid=ApexPages.currentPage().getParameters().get('id');

        contact contact1=[select id,recordtype.name from contact where id=:conid];

        if(contact1.recordtype.name=='new Contact')

        {

            displaybt=true;

        }

        else

        {

            displaybt=false;

        }

    }

 

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

palak agarwalpalak agarwal

Hi Navatar,

 

Thanks for your reply, but I want to display buttons according to recordTypes in list view.

Currently I am using following snippet,

 

<apex:page tabStyle="contact" controller="contactTab">
<style>
.btn:not(.avoidMe){
 
display: none;
 
}
</style>
<apex:pageBlock >




        <apex:enhancedList listId="00BP0000000UbE5" height="600" customizable="true" rowsPerPage="25"  >
   
                </apex:enhancedList>

                
    <!-- <apex:listViews type="Contact">
   
        <apex:facet name="header">
                    <table cellspacing="0" cellpadding="0" border="0">
                <tbody>
                    <tr>
                        <td class="pbTitle"></td>
                        <td ><input type="button" value="New Contact" class="btn" onClick="navigateToUrl('https://cs4.salesforce.com/003/e?retURL=%2F003%2Fo&RecordType=012P0000000Crvg&ent=Contact');" /></td>
                        <td class="pbHelp"></td>
                    </tr>
                </tbody>
               </table>
        
                   </apex:facet>
    </apex:listViews> -->
</apex:pageBlock>   
</apex:page>

 

 

Above snippet hides all the custom list buttons added to contact. But I want to hide them according to the ID of listView or according to the recordtype of contact.

 

With Regards

Palak Agarwal

devindiaadevindiaa
Hi Palak, Did you find an answer to this? I am also usinf enhanced list and not able to hide custom buttons on the basis of profiles