You need to sign in to do that
Don't have an account?
Nick Keehan
VF page - Search and edit Cases - Not updating/showing cases correctly
Hi Everyone.
Hope someone can help.
Looking to have a Search and Edit VF page for cases. I have modified a Jeffdouglas code to work with cases (SEE- http://blog.jeffdouglas.com/2010/04/07/easily-search-and-edit-records-with-visualforce/ ) however when searching and bringing up a record it doesnt show the Case number, Picklist values from the case, and doesnt populate the case with new details.
It does "Edit" the case as it shows that i last modified by me, however doesnt update the case fields.
Heres My Code
VF PAGE
Controller
Missing Case number, and no pick list options.
Modified by me, however no fields have been updated
Any help would be apreciated.
Nick
Hope someone can help.
Looking to have a Search and Edit VF page for cases. I have modified a Jeffdouglas code to work with cases (SEE- http://blog.jeffdouglas.com/2010/04/07/easily-search-and-edit-records-with-visualforce/ ) however when searching and bringing up a record it doesnt show the Case number, Picklist values from the case, and doesnt populate the case with new details.
It does "Edit" the case as it shows that i last modified by me, however doesnt update the case fields.
Heres My Code
VF PAGE
<apex:page standardController="Case" extensions="ItemEditController"> <apex:sectionHeader title="{!Case.CaseNumber}" subtitle="Case Search and Edit"/> <apex:form > <apex:pageBlock mode="edit" id="block"> <apex:pageBlockButtons location="both"> <apex:commandButton action="{!save}" value="Save Records"/> <apex:commandButton action="{!cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockSection > <apex:pageBlockSectionItem > <apex:outputLabel for="searchText">Case Number</apex:outputLabel> <apex:panelGroup > <apex:inputText id="searchText" value="{!searchText}"/> <apex:commandButton value="Search" action="{!search}" rerender="resultsBlock" status="status"/> </apex:panelGroup> </apex:pageBlockSectionItem> </apex:pageBlockSection><br/> <apex:actionStatus id="status" startText="Searching... please wait..."/> <apex:pageBlockSection title="Search Results" id="resultsBlock" columns="1"> <apex:pageBlockTable value="{!searchResults}" var="item" rendered="{!NOT(ISNULL(searchResults))}"> <apex:column value="{!Case.CaseNumber}" headerValue="Item" width="100"/> <apex:column headerValue="Value" width="200"> <apex:inputField value="{!Case.Description}"/> </apex:column> <apex:column headerValue="Value" width="200"> <apex:inputField value="{!Case.Referral_Status__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Controller
public with sharing class ItemEditController { private ApexPages.StandardController controller {get; set;} public List<Case> searchResults {get;set;} public string searchText {get;set;} // standard controller - could also just use custom controller public ItemEditController(ApexPages.StandardController controller) { } // fired when the search button is clicked public PageReference search() { String qry = 'select id, CaseNumber, Referral_Status__c, Description from Case ' + 'where Case.CaseNumber LIKE \'%'+searchText+'%\' order by Case.CaseNumber'; searchResults = Database.query(qry); return null; } // fired when the save records button is clicked public PageReference save() { try { update searchResults; } Catch (DMLException e) { ApexPages.addMessages(e); return null; } return new PageReference('/'+ApexPages.currentPage().getParameters().get('id')); } // takes user back to main record public PageReference cancel() { return new PageReference('/'+ApexPages.currentPage().getParameters().get('id')); } }
Missing Case number, and no pick list options.
Modified by me, however no fields have been updated
Any help would be apreciated.
Nick
Hope this helps.
All Answers
Hope this helps.
This worked perfectly. Still have an issue with the finished url. Seems to go to .com/null instead of the record. any chance you know how to correct this. Thanks for your help again.
Nick
I am guessing currently in your code, for some reason, ApexPages.currentPage().getParameters().get('id') is returning null.