+ Start a Discussion
reema_agarwalreema_agarwal 

Help with visualforce pages

Hello

 

I want to create a non editable visualforce page named asset history.In that page i want a look up field form which when we search the particular asset it should show the fields like Name,Status,Contact.Name.

 

Also i want to show the field caseNumber in that  page from the case object.

The relationship between case and asset is that there is an asset lookup in the case object.

 

can someone please help me.

 

Thanks!

BewitchedBewitched

Hi,

 

See this Data Model for case :-

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_support.htm

 

Asset is not available in case by default, but it is there in the standard field of Case. You need to add this field in Page Layout..

 

Eg,SELECT AccountId,AssetId FROM Case limit 5

 

Hope this helps..

 

Please mark this answer as solved if it helped you..

 

 

Thanks,

Tulika

reema_agarwalreema_agarwal

Hi 

 

I have written the code below and i am getting the fields of asset name,status and contact after i enter the asset name in the search text.

 

I also want the caseNumber from cases when i search a particular asset as i have created an asset lookup in the case object. How can i do it can u help me.

 

and also i am entering the asset name in the search text box how can i make it a look up so that i can select from the look up.

 

Controller class:

 

public class theController {
String searchText;
List<Asset> results;

public String getSearchText() {
return searchText;
}
public void setSearchText(String s) {
searchText = s;
}
public List<Asset> getResults() {
return results;
}
public PageReference doSearch() {
results = (List<Asset>)[FIND :searchText RETURNING Asset(Name,Status,Contact.Name)][0];

return null;
}

}

 

VF Page:

<apex:page controller="theController" >
<apex:form >
<apex:pageBlock mode="edit" id="block">
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
<apex:outputLabel for="searchText">Search Text</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="searchText" value="{!searchText}"/>

<apex:commandButton value="Go!" action="{!doSearch}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}">
<apex:column value="{!l.name}" />
<apex:column value="{!l.status}"/>
<apex:column value="{!l.contact.name}" />

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>



 

Please help me.

 

Thanks!