• Vaibhav Sule
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello,
Is it possible in Apex to update a particular field in a custom object for a list of those objects at the same time?

Here's what I am trying to do:
I have a custom object 'myCustomObj', which has a custom field 'myCustomField'.
I have a list of these objects created  already. I want to update the 'myCustomField' for all these objects.

Here's a snippet of my code, which is creating the list of objects correctly, but the update function doesn't seem to work.

 myCustomObj[] myList = new List<myCustomObj>();
 myList = [Select Name, ID, myCustomField from myCustomObj]; //this list gets created as expected
       integer max = mylist.size();
       for (integer i = 0; i< max; i++){
           Decimal x = myList[i].myCustomField; //I am able to read the value in this custom field correctly for all objects in the list 
           myList[i].myCustomField = x + 1;
           update myList[i];
       }
       update myList;//this seems to just update the list. How do I actually update the custom object?

Thanks in advance



 
Hello, I am a complete noob to salesforce. I am trying to test the InboundEmailHandler, and I wrote the following test class:

@IsTest
private class MMmeetingemailTest
{
    Messaging.InboundEmail email1 = new Messaging.InboundEmail();
    Messaging.InboundEnvelope env1 = new Messaging.InboundEnvelope();
    
    // Create the email body
    email1.plainTextBody = 'This should become a note';
    email1.fromAddress = 'test@test.com';
    string contactEmail  = 'jsmith@salesforce.com';
    email1.subject = 'a01O000000ZW5mo';
    MMmeetingemail mmemail = new MMmeetingemail();
    
    Test.startTest();
    Messaging.InboundEmailResult result = mmemail.handleInboundEmail(email1,env1);
    Test.stopTest();    
    System.assert (result.success , 'InboundEmailResult returned a failure message');    
}

However, I keep getting the following error: "unexpected token: '=' " for the line " email1.plainTextBody = 'This should become a note'; "
I don't understand what is incorrect here, since I am simply trying to assign a value to a valid object property.

Any help is appreciated.
Thanks!
 
Hello,
Is it possible in Apex to update a particular field in a custom object for a list of those objects at the same time?

Here's what I am trying to do:
I have a custom object 'myCustomObj', which has a custom field 'myCustomField'.
I have a list of these objects created  already. I want to update the 'myCustomField' for all these objects.

Here's a snippet of my code, which is creating the list of objects correctly, but the update function doesn't seem to work.

 myCustomObj[] myList = new List<myCustomObj>();
 myList = [Select Name, ID, myCustomField from myCustomObj]; //this list gets created as expected
       integer max = mylist.size();
       for (integer i = 0; i< max; i++){
           Decimal x = myList[i].myCustomField; //I am able to read the value in this custom field correctly for all objects in the list 
           myList[i].myCustomField = x + 1;
           update myList[i];
       }
       update myList;//this seems to just update the list. How do I actually update the custom object?

Thanks in advance



 
Hello, I am a complete noob to salesforce. I am trying to test the InboundEmailHandler, and I wrote the following test class:

@IsTest
private class MMmeetingemailTest
{
    Messaging.InboundEmail email1 = new Messaging.InboundEmail();
    Messaging.InboundEnvelope env1 = new Messaging.InboundEnvelope();
    
    // Create the email body
    email1.plainTextBody = 'This should become a note';
    email1.fromAddress = 'test@test.com';
    string contactEmail  = 'jsmith@salesforce.com';
    email1.subject = 'a01O000000ZW5mo';
    MMmeetingemail mmemail = new MMmeetingemail();
    
    Test.startTest();
    Messaging.InboundEmailResult result = mmemail.handleInboundEmail(email1,env1);
    Test.stopTest();    
    System.assert (result.success , 'InboundEmailResult returned a failure message');    
}

However, I keep getting the following error: "unexpected token: '=' " for the line " email1.plainTextBody = 'This should become a note'; "
I don't understand what is incorrect here, since I am simply trying to assign a value to a valid object property.

Any help is appreciated.
Thanks!