You need to sign in to do that
Don't have an account?
Sreekanth Naraboina
Updating Existing case Records from home page through Visual Force Page
i need to update case object status and Noted field for exisiting listed records.
public with sharing class TestCaseUpdateClass {
public list<case> caseList{get;set;}
public list<case> updateCaseList{get;set;}
public list<case> upCaseList{get;set;}
public String casestatus{get;set;}
public String casenotes{get;set;}
public TestCaseUpdateClass(ApexPages.StandardController controller) {
caseList=new list<case>();
updateCaseList=new list<case>();
list<string> allIdsList = new list<string>();
//Getting ids from the url
string AllIds = apexpages.currentpage().getparameters().get('AllIds');
if(AllIds != null && AllIds != ''){
//Spliting all ids in list to make a query
allIdsList = AllIds.split('-');
if(allIdsList != null && allIdsList.size() > 0){
//final query on case list
caseList= [select id,Status,Notes__c from Case where id In : allIdsList];
}
}
}
public void valueget(){
casestatus=System.currentPageReference().getParameters().get('Mahavir');
casenotes=System.currentPageReference().getParameters().get('notesget');
system.debug('Status Value in valueget-->>'+casestatus);
system.debug('notes Value in valueget-->>'+casenotes);
}
public PageReference Save(){
system.debug('Status Value in save-->>'+casestatus);
system.debug('notes Value in valueget-->>'+casenotes);
for(case cs:caseList){
cs.Status=casestatus;
cs.notes__c=casenotes;
updateCaseList.add(cs);
}
update updateCaseList;
system.debug('Updated List-->'+updateCaseList);
PageReference pageRef;
pageRef = new PageReference('/home/home.jsp');
pageRef.setRedirect(true);
return pageRef;
}
}
Visualforce page:
apex:page standardController="case" extensions="TestCaseUpdateClass" >
<script type="text/javascript">
function Callmefunc(id)
{
var statusVal = '';
var type = document.getElementById(id).value;
statusVal = type; check(statusVal);
alert(statusVal);
}
function Callmefuncnotes(id) {
var typenotes = '';
var typenotes = document.getElementById(id).value;
notesVal = typenotes; notes(notesVal);
alert(notesVal);
}
</script>
<apex:form >
<apex:pageBlock >
<apex:actionFunction name="check" action="{!valueget}" reRender="refresh">
<apex:param name="Mahavir" value="" />
</apex:actionFunction>
<apex:actionFunction name="notes" action="{!valueget}" reRender="refresh1">
<apex:param name="notesget" value="" />
</apex:actionFunction> <apex:pageBlockSection columns="1">
<apex:inputField value="{!case.Status}" rendered="true" label="Status" style="width:15%" id="check" onchange="Callmefunc('{!$Component.check}')"/>
<apex:inputField value="{!case.Notes__c}" style="width:30%" id="notes" onchange="Callmefuncnotes('{!$Component.notes}')"/> </apex:pageBlockSection>
<apex:outputPanel id="refresh">
</apex:outputPanel>
<apex:outputPanel id="refresh1">
</apex:outputPanel> <
apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class TestCaseUpdateClass {
public list<case> caseList{get;set;}
public list<case> updateCaseList{get;set;}
public list<case> upCaseList{get;set;}
public String casestatus{get;set;}
public String casenotes{get;set;}
public TestCaseUpdateClass(ApexPages.StandardController controller) {
caseList=new list<case>();
updateCaseList=new list<case>();
list<string> allIdsList = new list<string>();
//Getting ids from the url
string AllIds = apexpages.currentpage().getparameters().get('AllIds');
if(AllIds != null && AllIds != ''){
//Spliting all ids in list to make a query
allIdsList = AllIds.split('-');
if(allIdsList != null && allIdsList.size() > 0){
//final query on case list
caseList= [select id,Status,Notes__c from Case where id In : allIdsList];
}
}
}
public void valueget(){
casestatus=System.currentPageReference().getParameters().get('Mahavir');
casenotes=System.currentPageReference().getParameters().get('notesget');
system.debug('Status Value in valueget-->>'+casestatus);
system.debug('notes Value in valueget-->>'+casenotes);
}
public PageReference Save(){
system.debug('Status Value in save-->>'+casestatus);
system.debug('notes Value in valueget-->>'+casenotes);
for(case cs:caseList){
cs.Status=casestatus;
cs.notes__c=casenotes;
updateCaseList.add(cs);
}
update updateCaseList;
system.debug('Updated List-->'+updateCaseList);
PageReference pageRef;
pageRef = new PageReference('/home/home.jsp');
pageRef.setRedirect(true);
return pageRef;
}
}
Visualforce page:
apex:page standardController="case" extensions="TestCaseUpdateClass" >
<script type="text/javascript">
function Callmefunc(id)
{
var statusVal = '';
var type = document.getElementById(id).value;
statusVal = type; check(statusVal);
alert(statusVal);
}
function Callmefuncnotes(id) {
var typenotes = '';
var typenotes = document.getElementById(id).value;
notesVal = typenotes; notes(notesVal);
alert(notesVal);
}
</script>
<apex:form >
<apex:pageBlock >
<apex:actionFunction name="check" action="{!valueget}" reRender="refresh">
<apex:param name="Mahavir" value="" />
</apex:actionFunction>
<apex:actionFunction name="notes" action="{!valueget}" reRender="refresh1">
<apex:param name="notesget" value="" />
</apex:actionFunction> <apex:pageBlockSection columns="1">
<apex:inputField value="{!case.Status}" rendered="true" label="Status" style="width:15%" id="check" onchange="Callmefunc('{!$Component.check}')"/>
<apex:inputField value="{!case.Notes__c}" style="width:30%" id="notes" onchange="Callmefuncnotes('{!$Component.notes}')"/> </apex:pageBlockSection>
<apex:outputPanel id="refresh">
</apex:outputPanel>
<apex:outputPanel id="refresh1">
</apex:outputPanel> <
apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>