• ChopaForce
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 7
    Replies

I need to create(and I have zero apex experience) a simple trigger that will do the following:

 

//psuedo code

if (the new case owner is not in the same case team as the old case owner) {

                       increment a field by 1

}

 

else {

 nothing

}

 

its for the case object

 

Any help would be greatly appreciated

 

Hello, 

 

I am trying to assign an Id to a string variable (parentId).

The logic is the following:  if the Account of the Contact has a parent account then use the parent Account id otherwise read the Account Id.

 

The issue raises when I am assigning the Parent Account ID   (c.Account.Portal_Parent_Account__c) to my variable.

I ran the query within the SOQL editor ( eclipse schema ) and it returned me with an id for the Portal_Parent_Account. 

 

here's my code:

 

for(Contact c : [Select Account.Portal_Parent_Account__c,Account.Id from Contact where id =: contactid limit 1])
{
    if(c.Account.Portal_Parent_Account__c !='' && c.Account.Portal_Parent_Account__c != null) 
    {
         parentid = c.Account.Portal_Parent_Account__c;
         system.debug('******************Parent ID IF:' + parentid);
    }
    else
    {
         parentid = c.Account.Id;
         system.debug('******************Parent ID ELSE:' + parentid);
    }
}

 

Please note that I am not doing any insert or update before this code. I'm suspecting that maybe something is wrong when using 2 levels of hierarchy (parent of parent) ? Perhaps a lazy loading scenario ? 

 

Thank you for reading my post.

Hello,

 

about a year ago, I coded a batchable class that is scheduled to run every night. The number of batches is about 2500.

I've noticed that sometimes, the apex job status is set to "Aborted" after completing 20% of his job. I was wondering if there's any reason / factor I could look for to find out why the job is being aborted.  Please note that I did not receive any "System Exception" email from salesforce.

 

Thank you,

 

Chopa

 

Hi team,

 

I am wrting a Trigger to send an email whenever a Visit__c (custom object) record is created. Visit__c has a custom field named Poc_1_c which is nothing but a look up to contact.

So now when I create a Visit record the email should go to the POC.

Below is the Trigger i wrote and the error i am getting

 

trigger Send_Email_Visit on Visit__c (after insert,after update) {

Set<Id> Poc1IdSet = new Set<Id>();
  for(Visit__c Visit :Trigger.new){
  Poc1IdSet.add(Visit.POC_1__c);
  List<String> List1 = new List<String> ([Select Email from Contact where id in :Poc1IdSet]);
     
  Messaging.SingleEmailMessage MessageEmail = new Messaging.SingleEmailMessage();
 
   String toaddress = new String[] {List1.Email};
  
  
   if(Visit.Send_Email__c ==True && Visit.Portfolio__c =='Walmart')
        {
        MessageEmail.setTemplateId('00XK0000000QN37');
        MessageEmail.setTargetObjectId(Visit.CreatedByID);
        MessageEmail.setToAddresses (toaddress);
        MessageEmail.setSaveAsActivity(False);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {MessageEmail});
        }
        }
   
   }

Error: Compile Error: Invalid initial value type LIST<Contact> for LIST<String> at line 6 column 24

 

Can ANyone please help me on this?

 

Thanks in advance

Hello, 

 

I am trying to assign an Id to a string variable (parentId).

The logic is the following:  if the Account of the Contact has a parent account then use the parent Account id otherwise read the Account Id.

 

The issue raises when I am assigning the Parent Account ID   (c.Account.Portal_Parent_Account__c) to my variable.

I ran the query within the SOQL editor ( eclipse schema ) and it returned me with an id for the Portal_Parent_Account. 

 

here's my code:

 

for(Contact c : [Select Account.Portal_Parent_Account__c,Account.Id from Contact where id =: contactid limit 1])
{
    if(c.Account.Portal_Parent_Account__c !='' && c.Account.Portal_Parent_Account__c != null) 
    {
         parentid = c.Account.Portal_Parent_Account__c;
         system.debug('******************Parent ID IF:' + parentid);
    }
    else
    {
         parentid = c.Account.Id;
         system.debug('******************Parent ID ELSE:' + parentid);
    }
}

 

Please note that I am not doing any insert or update before this code. I'm suspecting that maybe something is wrong when using 2 levels of hierarchy (parent of parent) ? Perhaps a lazy loading scenario ? 

 

Thank you for reading my post.

I need to create(and I have zero apex experience) a simple trigger that will do the following:

 

//psuedo code

if (the new case owner is not in the same case team as the old case owner) {

                       increment a field by 1

}

 

else {

 nothing

}

 

its for the case object

 

Any help would be greatly appreciated

 

Hi All,

 

   Is there anyway to see full debug?

 

 Actually I am getting one error, while executing my opportunity wizard, but I could not see that error in my debug log. 

 What I am suspecting is: Showing Debug is not in full length.....becoz it might be in full of Size, So it shows half debug only.

 

Is there any way see full debug?  If I can see full debug, I may see In which line error occurs.

 

 

Any help would be greatly appreciated...!!

 

-Srinu

  • June 21, 2012
  • Like
  • 0

I have created List 1 and List 2

 

after creating objects to 2 diff classes I have added some elements.

 

List1.add(obj1);  // adding obj1 to the List 1

List2.add(obj2)  // adding obj2 to the List 2

 

Return type for both the Lists are different...

 

now I would like to return List 2 on debug logs but List 2 should contains elements of both List 1 and List 2...

 

Please try to resolve this..

thank u so much ,,,,, 

During a batch apex job I have noticed the number of Total Batches is changing, lowering. It starts high and then as the job progresses the number starts to lower. It would also appear that the batch apex job is missing some of the records that should have been originally queried and are never being processed by the batch apex class.

 

Here are some images showing the drop as the batch job progresses:

1670 Total Batches

 

1623 Total Batches

 

1527 Total Batches after complete

 

The difference is 143 batches or 29,000 records which is exactly how many records are not being processed.

 

This is bizarre. Any ideas?

 

Thanks,

Jason