function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vanessa veronvanessa veron 

Modify Method Apex

Hello

I have an apex page that lists the jobs created.
I would like to MODIFY and DELETE a job.

I did a method to delete and it works.
I'm not getting to do the MODIFY method that will catch the values ​​of the job (CronTrigger + MAIL informed the creation of this job) save and submit a second Visualforce page into inputText and selectOption.

The code:

APEX:

....

//CREATE JOB SCHEDULABLE
global void schedulejob(){               
        String email = getMail();
        String heu = getHour();
        String min = getMinute();
        String jMois = getDayMonth();
        String leMois = getMonth();
        String jSemaine = getDayWeek();
                     
        String NomJobSchedulable = nomJob;

        CLASS p = new CLASS (email , heu, min, jMois, leMois,jSemaine);   

        String expression = '00'+' '+min+' '+heu+' '+jMois+' '+leMois+' '+jSemaine ;      
        system.schedule(NomJobSchedulable , expression, p);
}

//DELETE JOB
public void deleteJob() {

if(!String.isBlank(strJobName))
{
    idJobDel= new List<CronTrigger>();
    idJobDel= [SELECT  Id FROM CronTrigger where CronJobDetail.Name =: strJobName];
    System.abortJob(idJobDel[0].id);
}
else
{
system.debug('NOT Job Name');
}
   }

//MOTIFY JOB -- like as .....

public void modifier (){

testeInfos = getInfos.split('/');

String mailMod = testeInfos.get(0);
setMail(mailMod);

deleteJob();
PageModify();
}


VISUALFORCE

                 <apex:column >
                    <apex:commandButton value="M" oncomplete="refreshPage();" action="{!modifier}"/>
                </apex:column>
Help me plese!
Thank you
VPROKVPROK
Will the standard edit page fit you?
You can return page reference to the standard edit page. Just copy the URL from brouser while editing a job, and then return the page reference to this page inside your edit method.
vanessa veronvanessa veron
I used rerender and the action dont work with rerender...

What do you do???
VPROKVPROK
no no, inside your modify method. put the return type to PageReference.
and then in the end return pageReference object to the page you need.
google pageReference class, it is quite simple to understand.
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_system_pagereference.htm
vanessa veronvanessa veron
Hii...

can you give me an example?

I used pageReference class in a method:

public PageReference PageModify() {
    return Page.BBBBPage2;
}

VPROKVPROK
Sorry, could you describe more detailed what should you do when clicking modify. You need to get some values from a job and then what? what the 2nd page is for? you want to modify the job using the VF page? In this case if your 2nd page will be based on the same controller - you will not lose the context and will be able to get all the data you need and update the record. Or use this:
'partialURL' to '/' + 'recordID'
new PageReference('/apex/yourpagename'+recID);
something like this
vanessa veronvanessa veron
Hii

The 2nd page is based on the same controller...

1 - 1st page has a table with informations of the jobs schedulables...

<apex:actionfunction name="callDeleteJob" action="{!deleteJob}" rerender="panelRefresh" oncomplete="refreshPage();">
            <apex:param value="" name="ParamNom" assignTo="{!strJobName}" />
          </apex:actionFunction>
          
          <apex:actionfunction name="callModify" action="{!modifier}" >
            <apex:param value="" name="ParamModify" assignTo="{!strJobName}" />
          </apex:actionFunction>
          
          <apex:outputPanel id="panelRefresh"></apex:OutputPanel>
          <apex:pageBlockTable value="{!jobRecords}" var="ac" id="pbBlockTable">
              <apex:column headervalue="Nom de la Tâche" value="{!ac.CronJobDetail.Name}"/>
                <apex:column headervalue="Expression" value="{!ac.CronExpression}"/>
                
                <apex:column >
                    <apex:commandButton value="X" onClick="callDeleteJob('{!ac.CronJobDetail.Name}'); return false;" />
                </apex:column>
                
                 <apex:column >
                    <apex:commandButton value="M" onClick="callModify(); return false;"/>
                </apex:column>
                  
              </apex:pageBlockTable>

2 - I would like to get the values into my custom object (according to the row of the selected table) :
==> I create a job, the informations are saved on my object.

jobInfo = new GetJobValue__c (nomJob__c =NomJobSchedulable , Mail__c = email , 
Requete__c=req, Heure__c=heu, Minute__c=min, jourMois__c=jMois, mois__c=leMois, 
jourSemaine__c=jSemaine);
insert jobInfo;

3 - I would like to display this values (into my custom object)  into the inputsText and selctList of the 2nd page.

Help me please!!!
Thank you

VPROKVPROK
Okay, check this snipped, looks like you want this.

<apex:pageBlock >
     <apex:pageBlockTable value="{!cases}" var="c" >
      <apex:column headerValue="Action">
       <apex:commandLink value="View" action="/apex/PartnerCaseDetail?id={!c.Id}" />
      </apex:column>
      <apex:column value="{!c.CaseNumber}" headerValue="Case Number"/>
      <apex:column value="{!c.Contact.Name}" headerValue="Contact"/>
      <apex:column value="{!c.Subject}" headerValue="Subject"/>
      <apex:column value="{!c.Status}" headerValue="Status"/>
      <apex:column value="{!c.CreatedDate}" headerValue="Created Date"/>
     </apex:pageBlockTable>
    </apex:pageBlock>

WHERE /apex/PartnerCaseDetail shuld be changed to your custom Page name. in this case you will get the record you need.
vanessa veronvanessa veron
Thanks, but this is not what I want.

I would put the value of a variable APEX appearing in inputText and selectOption.
VPROKVPROK
Just tested. If you have the context on particullar record and use inputfields for this record -> the fields are filled in.
So if your controller uses a variable(in this case account) than referring to account.Name etc will fill these fields in.
<apex:page standardController="Account">
<apex:form >
            <apex:pageBlock >
             <apex:pageBlockSection title="My Content Section" columns="2">
                 <apex:inputField value="{!account.name}"/>
                 <apex:inputField value="{!account.site}"/>
                 <apex:inputField value="{!account.type}"/>
                 <apex:inputField value="{!account.accountNumber}"/>
             </apex:pageBlockSection>
            </apex:pageBlock>
</apex:form>           
</apex:page>

sorry if I got you wrong, but you pass to little information :)
vanessa veronvanessa veron
OK... Thank you...
vanessa veronvanessa veron
Hi...It dont work

I have a page 1 and page 2 . The page 1 call page 2 and passes the value of a variable to page 2.

When I click the button (within a table) I would like the page 2  to be called and contained the MAIL value given already.
How I do it ....

APEX:
global String mail{get;set;}

..............

public PageReference modifier(){

if(!String.isBlank(strJobName))
{
    recupererInfosJob = new List<GetJobValue__c>();
    recupererInfosJob = [SELECT  mail__c FROM GetJobValue__c where mail__c =: strJobName];
    
    for(GetJobValue__c a: recupererInfosJob){
       string recordString = a.mail__c;
       garderJobInfo = recordString;
    }
}
else
{
system.debug('NOT Job Name');
}

mail = garderJobInfo;
   

return Page.BBBBPage2;


}

VISUALFORCE:

Mail..........:&nbsp;<apex:inputText styleClass="classeBig" value="{!mail}"/><br /><br />

         <apex:actionfunction name="callModify" action="{!modifier}" >
            <apex:param value="" name="ParamModify" assignTo="{!strJobName}" />
          </apex:actionFunction>
		  
		  ........

                 <apex:column >
                    <apex:commandButton value="M" onClick="callModify(); return false;"/>
                </apex:column>

Thank you!!

VPROKVPROK
so on the last page inputText should be prepopulated with the value from {!mail} attribute? So when the page loads the value is already there and you could change it?
If your pages are based on the same controller that there should be no problems with it. Is it blank on your page?
VPROKVPROK
Looks like here is the solution, even if you are using different controller:
http://salesforce.stackexchange.com/questions/4189/how-to-display-values-from-one-vf-page-into-another-vf-pge
vanessa veronvanessa veron
Yes....

I have a page 1 with a table...
I have a page 2 with the inputs and selectOption to create a new job.
The page 1 should call the page 2
The page 2 should display the values (according the row selected) in Page 1
VPROKVPROK
if you want checkboxes next to each table row, then consider using Wrapper classes. 
https://developer.salesforce.com/page/Wrapper_Class
last two links should be enough to create this functionallity :) Good Luck!
VPROKVPROK
I personally don't like selectOption. wrappers are more powerfull and controllable
vanessa veronvanessa veron
Can you gime me an example for display value into another page???

I have a page 1 with a table...
I have a page 2 with the inputs and selectOption to create a new job.
The page 1 should call the page 2
The page 2 should display the values (according the row selected) in Page 1
VPROKVPROK
here is the example. put it into your org - it should help :)
2 pages and one controller. 
1st page:
<apex:page controller="passValuesController">
<apex:form >
<apex:pageBlock >
     <apex:pageBlockTable value="{!accList}" var="a" >
	  	<apex:column headerValue="Selected"><apex:inputCheckbox value="{!a.check}"/></apex:column>
      	<apex:column value="{!a.acc.Name}" headerValue="Acc Name"/>
     </apex:pageBlockTable>
<apex:commandButton action="{!navigate}" value="navigate" id="theButton"/>     
</apex:pageBlock>

</apex:form>
</apex:page>
2nd page:

<apex:page controller="passValuesController">
<apex:form >
<apex:pageBlock >
     <apex:pageBlockTable value="{!accListSELECTED}" var="a" >
      	<apex:column value="{!a.acc.Name}" headerValue="Acc Name"/>
     </apex:pageBlockTable>
  
</apex:pageBlock>

</apex:form>
</apex:page>

and a controller:
public with sharing class passValuesController {
public list<AccWrapper> accList{get;set;}
public list<AccWrapper> accListSELECTED{get;set;}




public passValuesController(){
	accListSELECTED = new list<AccWrapper>();
	acclist = new list<AccWrapper>();
	list<Account> accs = new list<Account>();
	accs=[SELECT Name FROM Account];
	for(Account a:accs){
		accList.add(new AccWrapper(a));
	}
	
}

public pageReference navigate(){
	for(AccWrapper aw:accList){
		if(aw.check == true){
			accListSELECTED.add(aw);
		}
	}
	return new pageReference('/apex/passValuesPage2');
}

// WRAPPER CLASS
public class AccWrapper{
	public Account acc{get;set;}
	public Boolean check{get;set;}
	
	public AccWrapper(Account account){
		acc=account;
		check = false;		
	}
}

}


vanessa veronvanessa veron
Thank you!!!
Thank you!!!!!

it's exactly what I want to do ... but my values ​​are within a String ...

How do I tell the Apex page it will display the contents of a String?

VPROKVPROK
Almost the same :)

public class AccWrapper{
	public String str{get;set;}
	public Boolean check{get;set;}
	
	public AccWrapper(String inputString){
		str=inputString;
		check = false;		
	}
}
to reference the contents of a wrapper class use {!AccWrapper.str}
if we look on pages than it will look as follows:
<apex:pageBlockTable value="{!accList}" var="a" >
	  	<apex:column headerValue="Selected"><apex:inputCheckbox value="{!a.check}"/></apex:column>
      	<apex:column value="{!a.str}" headerValue="String inside wrapper"/>
     </apex:pageBlockTable>



VPROKVPROK
So like any class. For example, account has properties:
-Name
-Id
-AccountNumber and so on
in our case Wrapper has properties:
-str (string)
-check (boolean)

And you can create any properties you want :) Very powerfull approach.
vanessa veronvanessa veron
But I dont work with a wrapper class...

I have a shcedulable class: global class AAAAA implements System.Schedulable {....}

I would like to get the String value into class Apex and prepulate this value into input Text (Visualforce Page)
VPROKVPROK
you can wrap your class into wrapper(like I wrapped an account object(class)) and add the check property, than the framework is the same :)
Just try to use the pattern I showed inside your code :)

Gone home, good luck with your feature.
vanessa veronvanessa veron
Thank you!!!!