You need to sign in to do that
Don't have an account?
Linda 98
Custom button with Vf page
Created a custom object on record detail page.VF page will search records by using query in controller.
It has a input field and holds search text.I want to have more flexibity with the search text.It is being filled with value from record field.Like name of record.But i would like to give user to change the search text if he wants and still fit in the query.Like dynamic text field.
It has to work two ways,value from standard field and also should work if user chnages the value and give new value.Please help.
It has a input field and holds search text.I want to have more flexibity with the search text.It is being filled with value from record field.Like name of record.But i would like to give user to change the search text if he wants and still fit in the query.Like dynamic text field.
It has to work two ways,value from standard field and also should work if user chnages the value and give new value.Please help.
I have done the same thing i.e searching an account based on user string.
Please refer to the following code as it may be helpful in solving your problem.
Controller:
public with sharing class accsearchcontroller {
public list <account> acc {get;set;}
public string searchstring {get;set;}
public accsearchcontroller(ApexPages.StandardController controller) {
}
public void search(){
string searchquery='select name,id from account where name like \'%'+searchstring+'%\' Limit 20';
acc= Database.query(searchquery);
}
public void clear(){
acc.clear();
}
}
Vf Page:
<apex:page standardController="account" extensions="accsearchcontroller">
<apex:form >
<apex:inputText value="{!searchstring}" label="Input"/>
<apex:commandButton value="Search records" action="{!search}"/>
<apex:commandButton value="Clear records" action="{!search}"/>
<apex:pageBlock title="Search Result">
<apex:pageblockTable value="{!acc}" var="a">
<apex:column >
<apex:outputlink value="https://ap1.salesforce.com/{!a.id}">{!a.Name}</apex:outputlink>
</apex:column>
<apex:column value="{!a.id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
Hope it's clear.Thank you!
Was able to figure out my mistake. Thank you again for replying Deepali.