You need to sign in to do that
Don't have an account?
Venkata Sumedha singanamala
Displaying custome Confirm Messages
Firstly apologise for a lengthy querie
I have a small query ever I have a piece of code which will display the records of a user which are existing in Account and Emp. And I have a written a method “m1” which would diplay the “Confirm” messgae with the count of records available if not a message”No Customers found”.
My question is I have one record present in Account tab but not in Emp tab and when I click the search button I want the browser to be displayed with the Acount records and there should be a message
“No records found ” in EMP tab how can I do it ??
For the reference here I am attaching the code.
Visual Force program:
<apex:page controller="APtest9">
<apex:form>
<apex:pageBlock title="User Records">
<apex:pageBlockSection title="Search Section">
<apex:outputLabel value="Enter the User name"></apex:outputLabel>
<apex:inputText value="{!Na}"/>
<apex:commandButton value="Search" action="{!m1}" />
<apex:pageMessages></apex:pageMessages>
<apex:pageBlockSection title="Account Records">
<apex:pageBlockTable value="{!arecs}" var="items">
<apex:column value="{!items.id}"/>
<apex:column value="{!items.name}"/>
<apex:column value="{!items.billingcity}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlockSection>
<apex:pageBlockSection title="Employee Records">
<apex:pageBlockTable value="{!erecs}" var="items">
<apex:column value="{!items.name}"/>
<apex:column value="{!items.ID_no__c}"/>
<apex:column value="{!items.Client__c}"/>
<apex:column value="{!items.Basic_Salary__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class Aptest9 {
public string Na{set;get;}
public list<account> arecs{set;get;}
public list<EMP__c> erecs{set;get;}
public void m1(){
arecs=[select id,name,billingcity from account where name=:Na];
erecs=[select name,ID_no__c,Client__c,Basic_Salary__c from EMP__c where name=:Na];
integer cnt=[select count() from account where name=:Na];
if(cnt>0)
{
apexpages.addMessage(new apexpages.Message(apexpages.Severity.CONFIRM,cnt+ 'Record Found'));
}else{
apexpages.addMessage(new apexpages.Message(apexpages.Severity.CONFIRM,+ 'No Record Found'));
}
}
}
I have a small query ever I have a piece of code which will display the records of a user which are existing in Account and Emp. And I have a written a method “m1” which would diplay the “Confirm” messgae with the count of records available if not a message”No Customers found”.
My question is I have one record present in Account tab but not in Emp tab and when I click the search button I want the browser to be displayed with the Acount records and there should be a message
“No records found ” in EMP tab how can I do it ??
For the reference here I am attaching the code.
Visual Force program:
<apex:page controller="APtest9">
<apex:form>
<apex:pageBlock title="User Records">
<apex:pageBlockSection title="Search Section">
<apex:outputLabel value="Enter the User name"></apex:outputLabel>
<apex:inputText value="{!Na}"/>
<apex:commandButton value="Search" action="{!m1}" />
<apex:pageMessages></apex:pageMessages>
<apex:pageBlockSection title="Account Records">
<apex:pageBlockTable value="{!arecs}" var="items">
<apex:column value="{!items.id}"/>
<apex:column value="{!items.name}"/>
<apex:column value="{!items.billingcity}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlockSection>
<apex:pageBlockSection title="Employee Records">
<apex:pageBlockTable value="{!erecs}" var="items">
<apex:column value="{!items.name}"/>
<apex:column value="{!items.ID_no__c}"/>
<apex:column value="{!items.Client__c}"/>
<apex:column value="{!items.Basic_Salary__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class Aptest9 {
public string Na{set;get;}
public list<account> arecs{set;get;}
public list<EMP__c> erecs{set;get;}
public void m1(){
arecs=[select id,name,billingcity from account where name=:Na];
erecs=[select name,ID_no__c,Client__c,Basic_Salary__c from EMP__c where name=:Na];
integer cnt=[select count() from account where name=:Na];
if(cnt>0)
{
apexpages.addMessage(new apexpages.Message(apexpages.Severity.CONFIRM,cnt+ 'Record Found'));
}else{
apexpages.addMessage(new apexpages.Message(apexpages.Severity.CONFIRM,+ 'No Record Found'));
}
}
}
You can try this:-
Thanks,
Vatsal
Thanks for the help I have tried your code it is showin the below message what i exactly want is which ever block either the Account block or the Emp block doesnt have the respective persons record that specific block should show up the message as No records found will this be possible using apex code?
Please find the image for your reference.
thank you once again...
Regards,
Seshagiri
you can try this:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
Here in our condition:
rendered="{!erecs != null}"
It will return true if erecs contains something or else it will return false and pageBlocksection will not display.
kindly mark it as the best answer if this helps you..:)
Thanks,
Vatsal