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
Akshit HuriaAkshit Huria 

Show Delete and Edit command link if record created date is current date

<apex:page controller="pqr">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!links}" var="abc">
                <apex:column headerValue="changes"  >
                    <apex:commandLink value="{!abc}"  action="{!show}">
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>
                </apex:column>
                <apex:column headerValue=" Action">
                    <apex:commandLink value="Delete" action="{!del}" rendered="{!d}" >
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:commandLink value="Edit" action="{!edt}"  rendered="{!e}">
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="back" action="{!back}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class pqr
    {
    
        public List<String> links{get; set;}
        public String pp{get; set;}
        public List<quality__c> go{get; set;}
        public Boolean re{get; set;}
        public Boolean res{get; set;}
        public Boolean ed{get; set;}
        public Boolean cn{get; set;}
        public Boolean sv{get; set;}
        public Boolean e{get; set;}
        public Boolean d{get; set;}
        public pqr()
        {
            re=false;
            res=true;
            ed=true;
            links=new List<String>();
            AggregateResult[] ar=[select sdate__c from Quality__c group by sdate__c ];  
            for(AggregateResult a:ar)
            {
              String q= String.valueOf(a.get('sdate__c'));
              links.add(q);
            }
           date dt=System.today();
             String g=String.valueOf(dt);
            for(String p :links)
            {
                String[] re=p.split(' ');
                System.debug(re[0]);
                System.debug(g);
                if(re[0] != g)
                {
                    e=false;
                    d=false;
                }
                else
                {
                    d=true;
                    e=true;                
                }
                System.debug(d);
                
            }  
        }
        public PageReference show()
        {
            cn=false;
            ed=true;
            re=false;
            res=true;
            sv=false;
            go=new List<quality__c>();
            go=[select name, ab__c, bc__c, cd__c from quality__c where sdate__c=: pp];
            PageReference pr=new PageReference('/apex/task4_2');
            return pr;
        }
        public PageReference back()
        {
             PageReference pr=new PageReference('/apex/task4');
            return pr;
        }
        public PageReference back2()
        {
             PageReference pr=new PageReference('/apex/task4_1');
            return pr;
        }
        public void emode()
        {
            re=true;
            res=false;
            ed=false;
            cn =true;
            sv=true;
        }
        public void nmode()
        {
            re=false;
            res=true;
            ed=true;
            cn= false;
            sv=false;
        }
        public void tsave()
        {
            for(Quality__c s : go)
            {
                upsert s;
            }
            re=false;
            res=true;
            sv=false;
            cn=false;
            ed=true;
        }
        public PageReference del()
        { 
            go=new List<quality__c>();
            go=[select name, ab__c, bc__c, cd__c from quality__c where sdate__c=: pp];
            
            delete go;
            PageReference pf=new PageReference('/apex/task4_1');
            pf.setredirect(true);
            return pf;
        }
        public PageReference edt()
        {
            go=new List<quality__c>();
            go=[select name, ab__c, bc__c, cd__c from quality__c where sdate__c=: pp];
            re=true;
            res=false;
            PageReference pr=new PageReference('/apex/task4_2');
            return pr;
        }
    }
User-added image

 
Pankaj_GanwaniPankaj_Ganwani
Hi,

You can use rendered attribute of apex:commandLink to achieve this:
 
<apex:column headerValue=" Action">
                    <apex:commandLink value="Delete" action="{!del}" rendered="{!d==TODAY}" >
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:commandLink value="Edit" action="{!edt}"  rendered="{!e==TODAY}">
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>
                </apex:column>

 
Akshit HuriaAkshit Huria
Hi,
@Pankaj
Its not working
Pankaj_GanwaniPankaj_Ganwani
Okay, Can you please try with Now() function instead?
 
<apex:column headerValue=" Action">
                    <apex:commandLink value="Delete" action="{!del}" rendered="{!d==NOW}" >
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <apex:commandLink value="Edit" action="{!edt}"  rendered="{!e==NOW}">
                        <apex:param value="{!abc}" name="pp" assignTo="{!pp}" />
                    </apex:commandLink>
                </apex:column>

 
Akshit HuriaAkshit Huria
Thank You Pankaj
for your help