You need to sign in to do that
Don't have an account?
nesh
How to call apex class from List View Custom Button .. my sample code is here
How to call apex class from List View Custom Button ..my inside apex class code is here- how to use it...Please help me
INSIDE CLASS: 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; }
Hi Nesh,
To do this you need a VisualForce page and a controller extension.
The controller extension, let's call it "CreateTrainingSurveys.cls", will contain your code. I've optimized the code a bit to move the record type query out of the loop and to make the code easier to get code coverage:
The VF page, let's call it "CreateTrainingSurveys.page", should be something like this:
That's all you need. The button will launch this page, which will display for a moment and then return to the page that you came from. If you want, you could put some content on the page, like "Creating Training Surveys - Please Wait..."
Note that you must use the standard controller in order for the page to be available as a list view VF button for the object.
Then, you need to go to Setup | Create | Objects | Training__c and create your custom list view button.
Finally, add the custom button to the appropriate layout.
If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!
-Glyn Anderson
Certified Salesforce Developer | Certified Salesforce Administrator
All Answers
Hi Nesh,
To do this you need a VisualForce page and a controller extension.
The controller extension, let's call it "CreateTrainingSurveys.cls", will contain your code. I've optimized the code a bit to move the record type query out of the loop and to make the code easier to get code coverage:
The VF page, let's call it "CreateTrainingSurveys.page", should be something like this:
That's all you need. The button will launch this page, which will display for a moment and then return to the page that you came from. If you want, you could put some content on the page, like "Creating Training Surveys - Please Wait..."
Note that you must use the standard controller in order for the page to be available as a list view VF button for the object.
Then, you need to go to Setup | Create | Objects | Training__c and create your custom list view button.
Finally, add the custom button to the appropriate layout.
If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!
-Glyn Anderson
Certified Salesforce Developer | Certified Salesforce Administrator
i want to display the all sobejct in visualforce page .. i want to check these sobject deletable,readable,writeable. for eg i want to display all sobject in dropdown box and check button in visualforcepage. when i click on check button, check wheather that sobject is deletable,readable,writeable..i done no how to get all sobjects in visualforce page.. plz help me frds
@php tool kit,
I might have an answer for you, but you need to post this new question in a new thread so that it can have its own solution. I'll look for your post and then I (and others) can help you out.
-Glyn
ok i ll post the my question in other thread..can u send me code ...
i want to display the all sobejct in visualforce page .. i want to check these sobject deletable,readable,writeable. for eg i want to display all sobject in dropdown box and check button in visualforcepage. when i click on check button, check wheather that sobject is deletable,readable,writeable..i done no how to get all sobjects in visualforce page.. plz help me frds
Ive been mucking around trying different variations of the string to pass as the parameter but the closest ive gotten is the value of the object id
heres a sample of what im doing
myRecords = {!GETRECORDIDS($ObjectType.thing__c)};
sforce.apex.execute("className", "methodName", {ids:"[WHAT GOES IN HERE]"});
i can see it pass in a string on the class, but its never a tring of ids that were selected
i understand the workaround of using a custom page and controller, but i think the users want a warning if no records are selected