You need to sign in to do that
Don't have an account?
When i click list view button Update field--using online java script
When i click list view button -selected records custom field are updated in corresponding records..Usong onclick javascript
My code :
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} //adds the proper code for inclusion of AJAX toolkit
var url = parent.location.href; //string for the URL of the current page
var records = {!GETRECORDIDS($ObjectType.Training__c)}; //grabs the Lead records that the user is requesting to update
var updateRecords = []; //array for holding records that this code will ultimately update
if (records[0] == null) {
//if the button was clicked but there was no record selected
alert
("Please select at least one record to update."); //alert the user that they didn't make a selection
} else { //otherwise, there was a record selection
for (var a=0; a<records.length; a++) { //for all records
var update_Train = new sforce.SObject("Training__c"); //create a new sObject for storing updated record details
update_Train.Id = records[a]; //set the Id of the selected Lead record
update_Train.Training_Status__c= 'Pass'; or update_Train.Status__c = true;
updateRecords.push(update_Train);
}
result = sforce.connection.update(updateRecords);
parent.location.href = url; //refresh the page
}
Above code doesnt update record .When i click Please give ur idea when click list button update or insert the custom field - please help me.
Nesh,
It looks like there is an unwanted "or" in the code:
update_Train.Training_Status__c= 'Pass'; or update_Train.Status__c = true;
This is probably causing Javascript to fail execution at that point. Change the code to:
update_Train.Training_Status__c= 'Pass';
update_Train.Status__c = true;
and see if that works.
-Glyn
Thanks for reply..onclick javscript code:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var url = parent.location.href;
var records = {!GETRECORDIDS($ObjectType.Training__c)};
var updateRecords = [];
if (records[0] == null) {
alert("Please select at least one record to update.");
} else {
for (var a=0; a<records.length; a++) {
var caseObj = new sforce.SObject("Training__c");
caseObj.Id = records[a];
if(caseObj.day1surveyflag__c==false && caseObj.T__c!= 'Day 1')
{
caseObj.T__c= 'Day 1';
}
updateRecords.push(caseObj);
}
result = sforce.connection.update(updateRecords);
parent.location.href = url;
}
Field update based on -onclick javascript does'nt cover my REQUIREMENT.after field update -i have set email alert that logic doesnt cover my requirement.SO I AM CHANGE MY LOGIC BELOW.PLS GIVE UR IDEA FOR THAT PROCESS.
TRAINING SURVEY PROCESS:
(Please give one example (Send training day 1survey button) for Calling Apex Class from List Custom Button)
I have two object.Training and training survey...training record lookup relationship with training
survey.training object have training start date custom field...training survey have traning__c
lookup field.Traing survey have survey type custom field.
Process: if training start date --today+1,today+2,today+3--will send trainingsurvey email (day 1
or day 2 or day3 )to corresponding taining object record.else will send drop training survey.i
have set formula field check box..day 1 flag,day3,day5--whenever flag true -i have created
schedule process...apex class will insert survey type under traning survey object .i have created
workflow email alert -when will u insert survey type will send corresponding survey to corresponding records.
MY APEX LOGIC for schedule process.
global class MyTrainingSurveyProcess implements Schedulable
{
global void execute(SchedulableContext SC)
{
// Sweep training object for day 2 , 3 & 5th day survey
List <training__c> t1 = new list <training__c>();
list <training_survey__c> ts2 = new list<training_survey__c>();
t1 = [ select day1surveyflag__c, day3surveyflag__c, day5surveyflag__c from training__c where day1surveyflag__c = true or day3surveyflag__c = true or day5surveyflag__c = true ];
for(training__c tx : t1)
{
training_survey__c ts = new training_survey__c();
ts.training__C = tx.id;
if(tx.day1surveyflag__c == true )
{
ts.Survey_Type__c = 'Day1';
}else
if(tx.day3surveyflag__c == true )
{
ts.Survey_Type__c = 'Day3';
}else
if(tx.day5surveyflag__c == true )
{
ts.Survey_Type__c = 'Day5';
}else
{
ts.Survey_Type__c = 'Dropped';
}
RecordType r = [Select id from Recordtype where sobjecttype = 'training_survey__c' and name= :ts.Survey_Type__c];
ts.RecordTypeid = r.id;
ts2.add(ts);
}
if(ts2 != null )
{
insert ts2;
}
}
}
My requirement :
A)If a Survey record has already been created for the specific Day, we just need to resend the
existing survey record link..(purpose:survey was not filled by person within the
timeframes specified)
Here i need manual list view button on training object.i want to have 4 buttons that represent each survey.when i click list button(day1,day3,day5,drop) cover above(A&B) two logic.
i know list button creation.
How to Calling Apex Class from List Custom Button?.Please give ur idea for Calling Apex Class from List Custom Button and how to cover above (A )two logic using apex class.Please give one example(Send training day 1survey button)..