• Mazlow Cohen SFDC
  • NEWBIE
  • 5 Points
  • Member since 2016
  • Salesforce Aadministrator
  • Google


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I want to create a javascript custom button on the case layout that will add a new case comment with the text "done" and change the status of the case to closed. I know how to change the status to closed. But I don't know how to add a new case comment using the javascript cutom button. Does anyone know how to do this?

Thanks!
Mazlow
Hi,

I was wondering how I could write a for loop instead of a for each loop to cycle through each object in the trigger. The reason being, I want to reference the number that object is in the List of objects in the trigger- later in the code after cycling through the loop. I have tried google searches and all the triggers seem to use this format- for each loop:

"for (User userInLoop : Trigger.new) {...}"

I tried using a for loop like this for account trigger- "for(Integer i = 0; i < Trigger.new.size(); i++) { 

Account a = Trigger.new.get(i);

//do some code on Account a...

}"


This kept giving me an error. Is this not allowed? 

Thanks!
Mazlow
Hi,

I was wondering how I could write a for loop instead of a for each loop to cycle through each object in the trigger. The reason being, I want to reference the number that object is in the List of objects in the trigger- later in the code after cycling through the loop. I have tried google searches and all the triggers seem to use this format- for each loop:

"for (User userInLoop : Trigger.new) {...}"

I tried using a for loop like this for account trigger- "for(Integer i = 0; i < Trigger.new.size(); i++) { 

Account a = Trigger.new.get(i);

//do some code on Account a...

}"


This kept giving me an error. Is this not allowed? 

Thanks!
Mazlow