• Andrew Wilkinson
  • SMARTIE
  • 680 Points
  • Member since 2012

  • Chatter
    Feed
  • 27
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 121
    Replies

I have a Workflow rule that creates a Task each time a specific type of Lead is created.  I have a custom field in this Task that needs to be populated upon creation but I cannot accomplish this with the Workflow so I am creating a trigger. 

 

I get the following error when I save the trigger

 

Error: Compile Error: unexpected token: '}' at line 5 column 12

 

Here is the trigger

 

trigger PubProductUpdate on Task (before insert){

    for (Task PU : Trigger.new){
        if (PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
            }
    {
    
    PU.Pub_Products__c = 'Pub Opening Pitch';
    }
}

 

I am new to Apex Triggers and not sure where my select criteria goes wrong. 

 

Thanks.

Hi guys,

 

I've searched high and low for some info on what I've done wrong and can't work it out.

 

I basically want to return a list of Prestart_Checklist__c that fall within a given date range and location - this works.

 

Then for each item in the list, I want to present a text box so that a user can update the name of the record. This displays correctly and retrieves the existing data - but the save button seems ineffectual. If I change any values in the inputfields and click save, the page refreshes, but no data is saved.

 

I know I'm missing something simple, but I've wasted too much time on this one to keep hacking away at it, so any suggestions are very welcome.

 

Page:

 

<apex:page action="{!initPage}" standardController="Prestart_Checklist__c" extensions="PSCLEditExtension" >

<apex:form >
    <apex:pageBlock title="Filter results" >
        <apex:pageBlockButtons location="bottom" >
            <apex:commandButton value="Go" reRender="dataTable" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1">
            <apex:inputField value="{!plantForLocation.Location__c}" />
            <apex:inputField value="{!psclForDate.Week_Ending__c}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

<apex:form >
    <apex:pageBlock title="Prestart Checklists" >
        <apex:pageBlockButtons location="bottom" >
            <apex:commandButton value="Save" action="{!save}" />
        </apex:pageBlockButtons>
        <apex:pageBlockTable id="dataTable" value="{!thisWeeksPSCLs}" var="pscl">
            <apex:column headerValue="Plant Name"> <apex:outputText value="{!pscl.Plant__r.Name}" /></apex:column>
            <apex:column headerValue="Plant Registration"> <apex:outputText value="{!pscl.Plant__r.Registration_Number__c}" /></apex:column>
            <apex:column headerValue="Prestart Checklist Number"><apex:inputField value="{!pscl.Name}" /></apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

 

Controller:

 

public with sharing class PSCLEditExtension {
    
    public Prestart_Checklist__c psclForDate{get; set;}
    public Plant__c plantForLocation{get; set;}
    
    public List<Plant__c> listPlant {
        get {
            return [select Id, Name from Plant__c];
        }
    }
    
    public List<Prestart_Checklist__c> listPSCL{get; set;}
    
    public List<Prestart_Checklist__c> thisWeeksPSCLs{
    	get {
	    	return [select Id, Name, Plant__r.Name, Plant__r.Registration_Number__c 
	                from Prestart_Checklist__c 
	    	        where Week_Ending__c = :psclForDate.Week_Ending__c 
	    	        and Plant__r.Location__c = :plantForLocation.Location__c];
} } } public PSCLEditExtension(ApexPages.StandardController controller) { psclForDate = new Prestart_Checklist__c(Week_Ending__c = Date.today().toStartOfWeek()); plantForLocation = new Plant__c(); } public void initPage() { } }

 

I'm trying to write a unit test for a trigger that captures the OwnerID of an Opportunity, and then populates a "Owner Details" field (giving us access to their entire user record) and a "Sales Manager" field (which is the user's manager).

 

I'm at 73% coverage, but the part that is not covered is the after update when the Opportunity Owner has changed. I've written into my test a scenario when the Opp Owner changes, but I'm getting the following error message:

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CopyOwnerInformation: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006S0000006jI1iIAE; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CopyOwnerInformation: maximum trigger depth exceeded Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i]: [] Trigger.CopyOwnerInformation: line 40, column 1: []

 

Here is the relevant code from my trigger. This is the part that I am trying to cover:

 

//Insert new owner details ID if it has changed
if(opp.Owner_Details__c == null || (opp.OwnerId != oldopp.OwnerID)){
List<Opportunity> OppsWithNewOwner = [SELECT ID, OwnerID, Owner_Details__c FROM Opportunity WHERE id in:trigger.new];

for (Integer i=0; i<OppsWithNewOwner.size(); i++){                                      
    OppswithNewOwner[i].Owner_Details__c = OppsWithNewOwner[i].OwnerID;}
    
    update OppsWithNewOwner;

    }

 

And here is my test class:

 

@isTest
private class Test_CopyOwnerInformation{
    static testMethod void CopyOwnerInformation(){
    
//set up test records
        
User user1 = new User();
        user1.firstname = 'Test User 1 First Name';
        user1.lastname = 'Test User 1 Last Name';
        user1.alias = 'user1';
        user1.email = 'testuser@unittest.com';
        user1.EmailEncodingKey = 'ISO-8859-1';
        user1.username = 'testuser1@unittest.com';
        user1.TimeZoneSidKey = 'America/Chicago';
        user1.LocaleSidKey = 'en_US';
        user1.ProfileId = '00e70000000sP2v';
        user1.LanguageLocaleKey = 'en_US';
        insert user1;
        
User manager2 = new User();
        manager2.firstname = 'Test Manager 2 First Name';
        manager2.lastname = 'Test Manager 2 Last Name';
        manager2.alias = 'mgr2';
        manager2.email = 'testmanager@unittest.com';
        manager2.EmailEncodingKey = 'ISO-8859-1';
        manager2.username = 'testmanager2@unittest.com';
        manager2.TimeZoneSidKey = 'America/Chicago';
        manager2.LocaleSidKey = 'en_US';
        manager2.ProfileId = '00e70000000sP2v';
        manager2.LanguageLocaleKey = 'en_US';
        insert manager2;
        
User user2 = new User();
        user2.firstname = 'Test User 2 First Name';
        user2.lastname = 'Test User 2 Last Name';
        user2.alias = 'user2';
        user2.email = 'testuser@unittest.com';
        user2.EmailEncodingKey = 'ISO-8859-1';
        user2.username = 'testuser2@unittest.com';
        user2.manager = manager2;
        user2.TimeZoneSidKey = 'America/Chicago';
        user2.LocaleSidKey = 'en_US';
        user2.ProfileId = '00e70000000sP2v';
        user2.LanguageLocaleKey = 'en_US';
        insert user2;
  
Account account = new Account();
        account.Name = 'Test Account';
        account.OwnerID = user1.id;
        account.web_site__c = 'test.com';
        account.industry = 'Entertainment';
        account.type = 'Advertiser';
        insert account;
        
Opportunity opportunity = new Opportunity();
        opportunity.AccountId = account.Id;
        opportunity.OwnerID = account.OwnerId;
        opportunity.Name = 'Test Opportunity';
        opportunity.StageName = 'Active';
        opportunity.CloseDate = System.today();
        opportunity.Amount = 1000.00;
        opportunity.Type = 'New Client';
        
//test  
    test.startTest();     
        insert opportunity;
    
//Validate that the Owner Details field was updated.
    opportunity = [SELECT OwnerId, Owner_Details__c, Owner_Details__r.ManagerID, SalesManager__c FROM Opportunity WHERE id = :opportunity.id];
    System.assertEquals(opportunity.OwnerId, opportunity.Owner_Details__c);
    System.assertEquals(opportunity.SalesManager__c, Opportunity.Owner_Details__r.ManagerID);

//Test that the Owner Details changes with an Opp Owner Change
   
        opportunity.OwnerId = user2.ID;
        update opportunity;
     test.stopTest();

//Validate that the Owner Details and Manager fields were updated.
    opportunity = [SELECT OwnerID, Owner_Details__c, Owner_Details__r.ManagerID, SalesManager__c FROM Opportunity WHERE id = :opportunity.id];
    System.assertEquals(opportunity.Owner_Details__c, user2.Id);
    System.assertEquals(opportunity.SalesManager__c, user2.Manager.Id);
    }
}

 Thank you for the help!

 

Hi all:

 

I'm a relative newb. I'm building an integration with salesforce.com via the SOAP API. I've reached a sticking point.  There is a report that  I need to access via the API.  I understand I can't access this directly, but the preferred approach is to mimic the SOQL that the report would be running, and generate the same data set that way.  

 

This seems straight forward, but I can't seem to make my SOQL get the same number of results as the report in salesforce.com.  Attached is a screen capture from the report page, as well as the SOQL I'm trying to use to generate the same data set.

 

 

 

 

 

SELECT Count(Id), (SELECT Contact.Name FROM Account.Contacts WHERE Contact.MaRS_Contact_Relationship__c INCLUDES ('Advisory Services Primary Contact') AND Contact.Inactive_Person_left_company__c = false) FROM Account WHERE MaRS_Company_Relationships__c INCLUDES ('Active VG Client', 'High Potential Client', 'SiG Client')

 

Can anyone see how these differ?  Or do you know how, in general, to get the SOQL that the report is executing?

Workflows fire when a record is "Edited". Does the workflow fire if some APEX code does an UPDATE on the record. I'm guessing not, but I can't find any documentation to support this theory.

TIA

Mike

I am getting and error 'unary increment/decrement can only be applied to numeric expressions'

Any other way to iterate over Date or DateTime? 

 

Date d1 = newTsscActivity.Start_Date_Time__c;
Date d2 = newTsscActivity.End_Date__c;
         	
   //DateTime dt1=DateTime.newInstance(d1, Time.newInstance(0, 0, 0, 0));
  //DateTime dt2=DateTime.newInstance(d2, Time.newInstance(0, 0, 0, 0));
         	
   for (date d=d1; d<=d2;d++){
         		
        DateTime dt1=DateTime.newInstance(d, Time.newInstance(0, 0, 0, 0));
         	
        String dayofweek = dt1.format('EEE');
         		
         		        		
    } 

 

 

 

 

 

  • December 03, 2012
  • Like
  • 0

I need to be able to select current year records from a sales history custom object.  The sales year is a text field in the format of CCYY. 

 

How do I code for this in my trigger select statement?

 

  • November 28, 2012
  • Like
  • 0

I have a trigger that fires on a custom object upon insert, update, or deletion.  The trigger updates the Associated Account record, but only if certain conditions are met.  It works fine when the conditions are met, but when they are not, I get the following error:

 

Apex trigger Contract2Account caused an unexpected exception, contact your administrator: Contract2Account: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Contract2Account: line 23, column 1

 

 

My trigger code is below:

 

trigger Contract2Account on Contract_Summary__c (after insert, after update, after delete)
{

Map<Id,Account> oppMap = new Map<Id,Account>();
Set<id> Ids = new Set<id>();

if(trigger.isInsert || trigger.isInsert)
{

for (Contract_Summary__c prgm : Trigger.new)
{
if(prgm.Type_of_Contract__c == 'Renewal' || prgm.Type_of_Contract__c == 'Initial MSA')
Ids.add(prgm.Account_Name__c);
}

Map<id,Account> acctMap2 = new Map<id,Account>([Select Id,Name,Contract_Summary__c from Account Where Id in :Ids]);

for (Contract_Summary__c prgm2 : Trigger.new)
{
if(prgm2.Account_Name__c != null)
{
Account a = acctMap2.get(prgm2.Account_Name__c);
a.Contract_Summary__c = prgm2.Id;

oppMap.put(a.id,a);
}
}
update oppMap.values();
}
if(trigger.isDelete)

{

for (Contract_Summary__c prgm : Trigger.old)
{
if(prgm.Type_of_Contract__c == 'Renewal' || prgm.Type_of_Contract__c == 'Initial MSA')
Ids.add(prgm.Account_Name__c);
}

Map<id,Account> acctMap2 = new Map<id,Account>([Select Id,Name,Contract_Summary__c from Account Where Id in :Ids]);

for (Contract_Summary__c prgm2 : Trigger.old)
{
if(prgm2.Account_Name__c != null)
{

Account a = acctMap2.get(prgm2.Account_Name__c);
a.Contract_Summary__c = null;

oppMap.put(a.id,a);

}
}
update oppMap.values();
}
}

  • November 21, 2012
  • Like
  • 0

I'm looking for an example of VF page code that does a client-side sort via jQuery that sorts a pageblocktable as opposed to one that using something tagged with regular HTML tags <table> <tr> <td>

 

Anyone have one?

 

I'd rather not give up the look-and-feel of pageblocktable and I'm just a novice at jQuery so it would take me too long to hack around by myself to get it to work.  I could do it but dont' have time allocated on the project for the research and experiment needed. 

 

 

-Ken

 

 

 

I have a trigger on task which basically checks the Task's call type and update fields on the corresponding account accordingly. (I omitted some parts since the test is only on the insert part)

 

trigger callType on Task (after insert, after update, after delete) {
    Account[] oa; 
    Account a;
    if(Trigger.IsDelete) { ... } 
else if(Trigger.IsUpdate) { ... } else if(Trigger.IsInsert) { for (Task t : Trigger.new) { oa = [SELECT Id, KYC_Completed__c, Check_in_Scheduled__c FROM Account where Id =:t.WhatId LIMIT 1]; //finds the account task is related to if(oa.size()>0){ a = oa[0]; }else return; //oa.size zero, the task is not related to account. abort mission. //if new trigger is check in or kyc call then respective fields should be true. if (t.Call_Type_aD__c == 'KYC Call') a.KYC_Completed__c = true; else if(t.Call_Type_aD__c == 'Check in') a.Check_in_Scheduled__c = true; else return; } } }

This is the (unfinished) test 

 

@isTest
private class callTypetest{
    static testMethod void testcallType() {
        callTypetest ctt = new callTypetest();
        //Make a new account
        Account a= new Account(
            Name = 'Test Account'
        );
        insert a;
        Task t = new Task(Call_Type_aD__c = 'KYC Call', WhatId = a.Id);
        insert t;
        update a;
        a = [SELECT Id, KYC_Completed__c FROM Account WHERE Id =: a.Id LIMIT 1];
        System.assertEquals(true, a.KYC_Completed__c);

    }

}

 Now my test is simple: when I make the task, the insert part of the trigger is activated (code coverage shows this when I check it). It should tick the KYC_Completed__c to true since the Call_Type_aD__c is KYC Call, and in fact that part of the code ran as shown by the code coverage. I've also updated the account as well as querying it again before the assertEquals. However the assertEquals says expect true, got false.

 

Any help is greatly appreciated!

Thanks in advance.

Hi i have to assign a task on the account selected by the user,i am stuck in between any help would be great

 

Page:

 

<apex:page controller="PractiseController">
    <apex:form >
      <apex:pageBlock >
      <apex:pageBlockSection columns="1">
      <apex:selectList size="1" value="{!selectValue}" label="Related to" onclick="">
        <apex:selectOptions value="{!Options}"></apex:selectOptions>
      </apex:selectList>
      <apex:inputTextarea value="{!comments}" label="Comments" />
      <apex:commandButton value="Done" action="{!assignTask}"/>
      </apex:pageBlockSection>
      </apex:pageBlock>
    </apex:form>
</apex:page>

 Sravan Alaparthi

 

 

Controller:

public with sharing class PractiseController{

   public List<SelectOption> options=new List<Selectoption>();
    public Id selectValue { get;set; }
     public string comments { get;set; }
//method to generate account names as picklist   
public List<SelectOption> getOptions(){

for(Account account:[Select ID,Name from Account]){
options.add(new SelectOption(account.id,account.Name));}

return options;
}

//method to assign a task
public pageReference assignTask(){


Task lt=new Task();
lt.what=//assign selected account to task

lt.Description=comments;

pageReference pr=new pageReference('/'+selectvalue);
return pr;
}
}

 

Ok I came up a trigger that is thin but does specifically what I need to do. Plus it works with the class in this post.

 

I have a few questions though, Seeing that the class is "CaseFunctions" we should be able to add even more case related functionality. I'm not so sure I'm using the trigger's variables, Trigger.New and Trigger.NewMap correctly.

 

I would like the trigger and class to be able to compare the oldMap as well as the newMap when we address adding more functions to this class.

 

Also, I need an opion on the class, it is currently only applies to one use case I can think of but it may be worth while to split it into separate functions later but that said,

 

How in a single trigger would I call the separate functions at the same time or should I just build three separate triggers.... Which would be the best approach in your thoughts???

 

Also, I would like to build an escape for the current user's profile "Name" for example "System Administrator". I have no idea how to achieve these things I've tried to work it out myself but unfortunately I haven't found the correct approach. Please help if you can field this one.

 

Thanks,

Steve Laycock

 

trigger CaseTriggerBeforeComplete on Case (before update)
{
      CaseFunctions.CaseValidationBeforeComplete(Trigger.new, Trigger.newMap);
}

 

public class CaseFunctions
{
   public static void CaseValidationBeforeComplete(Case[] caseRecs, Map<ID,Case> newMap)
   {
        List<Id> caseIds = new List<Id>();
        
        Id caseRecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PM Case' AND SObjectType = 'Case'].Id;

        Id TaskRecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PM Task' AND SObjectType = 'Task'].Id;
        
        for (Case c : caseRecs)
        {
            Case newRec = newMap.get(c.Id);
            if(c.RecordTypeId == caseRecordTypeId && (c.Status == 'Completed' || c.Status == 'Closed'))
            {
                 caseIds.add(c.Id);
            }
        }
        for(Training_Information__c customobj : [Select Id, Status__c,Case__c From Training_Information__c Where Case__c in: caseIds])
        {
            if(customobj.Status__c == 'Pending' || customobj.Status__c == 'Scheduled')
            {    
                 newMap.get(customobj.Case__c).addError('Training has not been completed.');
            }     
        }    
        
        for(Development_Request__c customobj : [Select Id, Stage__c,Case__c From Development_Request__c Where Case__c in: caseIds])
        {
            if(customobj.Stage__c != 'Completed' && customobj.Stage__c != 'Cancelled DR/ VOID' && customobj.Stage__c != 'Draft')
            {
                newMap.get(customobj.Case__c).addError('There are open Development Request associated with this Case.');
            }
        }  

        for(Task T : [Select Id, Status, WhatId, RecordTypeId From Task Where WhatId in: caseIds])
        {
            if(T.RecordTypeId == TaskRecordTypeId && (T.Status != 'Completed' && T.Status != 'Discarded'))
            {
                newMap.get(T.WhatId).addError('There are still open PM Task on this Case.');
            }
        }
    }    
}

 

I have a class that stores data from a custom object into a List.  The class sorts the list and does all the things it needs to do, but now I want to pass the data back to my visualforce page.

 

But!  I dont want to use pageblock or tabledata to render the values.  Everytime I reference my class, it errors out on me.  Here is some code:

First method in my class that is getting the data:

public class getOnboarding {
    public getOnboarding(ApexPages.StandardController Controller){   
    }
    public SFDC_Acct_Plan__c[] getPlanInfo(){
        List<SFDC_Acct_Plan__c> fields = new List<SFDC_Acct_Plan__c>();
             fields = [SELECT Planning_Year__c,
                              Sales_Agreement_in_Place__c,
                              Plan_Status__c,
                              Last_Plan_Revision__c,
                              Days_Between__c,                              
                              Non_Disclosure_Agreement_in_Place__c,
                              Number_of_assets_tracked__c,
                              On_Boarding_Packet_to_Customer__c,
                              Kickoff_Meeting_Completed__c,
                              Kickoff_Meeting_Completed_on__c                              
                         FROM SFDC_Acct_Plan__c
                        WHERE Account__c IN 
                                (SELECT AccountId 
                                   FROM AccountShare 
                                  WHERE UserOrGroupId=:Userinfo.getUserId())
                          AND (Plan_Status__c = 'Draft')
                       ];
        return fields;
    }        

 and I want to pass it to my VF page:

<apex:page showHeader="false" sidebar="false" standardController="SFDC_Acct_Plan__c" extensions="getOnboarding">
  <!-- --------------------------------------- -->
  <!-- ------------START OF STYLES------------ -->
  <!-- --------------------------------------- -->  
        <style>                        
            #onboardingStages {text-align: center; width:95%}
            .pbheader {background-color:#000000!important; color:#FF4D4D!important;}
            .pbsubheader {background-color:#FFFF85!important; color:#5a5a5a!important;}        
        </style>
  <!-- --------------------------------------- -->
  <!-- ------------ END OF STYLES ------------ -->
  <!-- --------------------------------------- --> 
  <h1>Welcome Back {!$User.FirstName}</h1><br/>
  <h2>Date: {!MONTH(TODAY())}/{!DAY(TODAY())}/{!YEAR(TODAY())}</h2> 
  <div id="onboardingStages">
    <apex:variable var="stage" value="{!StageImage}"/>
    <apex:image url="{!URLFOR($Resource.Stages, stage)}" />    
  </div>

 But I want to put the data into my own table.

If I reference my method {!PlanInfo.Plan_Status__c} it will not allow me to use the data (unless its in a pageBlock).  I have also tried using variables for this.

I basically want to pass it to an HTML table cell that I define later.

Anyone come across this before?  I know its something easy and silly ... but I cant get it.

Thank you,

TS

 

trigger CaseCloseNoOpen on Case (Before update) 
{
    


    List<Id> caseIds = new List<Id>();
    
        Id caseRecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PM Case' AND SObjectType = 'Case'].Id;

        Id TaskRecordTypeId = [SELECT Id FROM RecordType WHERE Name = 'PM Task' AND SObjectType = 'Task'].Id;

    for(Case c : Trigger.New)
    {
           if(c.RecordTypeId == caseRecordTypeId && (c.Status == 'Completed' || c.Status == 'Closed'))
       {
            caseIds.add(c.Id);
       }
      
    }
    
       
       for(Training_Information__c customobj : [Select Id, Status__c,Case__c From Training_Information__c Where Case__c in: caseIds])
        {
            if(customobj.Status__c == 'Pending' || customobj.Status__c == 'Scheduled')
            {
                Trigger.newMap.get(customobj.Case__c).addError('Training has not been completed.');
            }
        }

    for(Development_Request__c customobj : [Select Id, Stage__c,Case__c From Development_Request__c Where Case__c in: caseIds])
        {
            if(customobj.Stage__c != 'Completed' && customobj.Stage__c != 'Cancelled DR/ VOID' && customobj.Stage__c != 'Draft')
            {
                Trigger.newMap.get(customobj.Case__c).addError('There are open Development Request associated with this Case.');
            }
        }  

    for(Task T : [Select Id, Status, WhatId, RecordTypeId From Task Where WhatId in: caseIds])
        {
            if(T.RecordTypeId == TaskRecordTypeId && (T.Status != 'Completed' && T.Status != 'Discarded'))
            {
                Trigger.newMap.get(T.WhatId).addError('There are still open PM Task on this Case.');
            }
        }
              
}

 How can we make this trigger better?  It is a trigger made to do the validation of no open task, training information records or development request records, so that a case which is being used for project management can't be closed until all of these three LOOKUP related objects are all resolved/Completed.

 

The above code works but I have questions like would it make sense to use a trigger to pass the newmap + oldmap into a class to do all of the heavy lifting?

 

Also, when evaluating please consider which approach would be easier to get code coverage on and why?

 

Please help if you can.

 

Thank you,

Steve Laycock

Hi,

 

I am getting below error. 

 

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Active_Ingredients__c]: [Active_Ingredients__c]

 

 

Class.AddCompProduct_Test.myUnitTest: line 26, column 1

 

 

 

@isTest
private class AddCompProduct_Test {
    //Create Testing User
    private static User localUser;

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        createTestUser();
        
        System.runAs(localUser){
            // Run the tests as user with the System Administrator profile
            Test.startTest();
            Territory__c testT = new Territory__c(Name = 'tesTerritory');
            insert testT;
       
            Post_Code__c postCode = new Post_Code__c(Country__c = 'Australia', Name = '1234', Town__c = 'TestTown',
                            State__c = 'testState',Territory__c = testT.Id);
             insert postCode;
            Account testAccount = new Account(name='TEST_ACCOUNT',Country__c = 'Australia', Town__c = 'TestTown', Post_Code1__c='1234', MobilePhone__c='+61-4444-333-333',Phone ='+61 (22) 4444 4444');
            insert testAccount;
           
            Crop__c crop;
            insert (crop=new Crop__c(Name = 'Funny ANZ Crop'));
           
            Active_Ingredient__c Ingredient;
            insert (Ingredient=new Active_Ingredient__c (Name = 'CP 20mg/L'));
            
                       
            Competitor_Product__c cp1 = new Competitor_Product__c(  Active__c=true, Active_Ingredient__c = 'CP 20mg/L', Name='CP COMP ANZ ');
            insert cp1;
            Competitor_Product__c cp2 = new Competitor_Product__c(  Active__c=true, Species__c = 'Apple', Name='Seeds COMP ANZ ');
            insert cp2;
           
                       
           
           
            AddCompProduct controller = new AddCompProduct();
           
            controller.options.country = 'Australia';
            controller.options.filterCP = new string[]{'Competitor CP'};
            controller.options.filterSE = new string[]{'Competitor Seeds'};
            controller.options.pageSizes = new integer[]{10};
           
            Set<string> x;
            x = controller.options.productFamilyFilterCP;
            x = controller.options.productFamilyFilterSE;
            x = controller.options.productFamilyFilter;
           
            List<SelectOption> so;
           
            so = controller.options.PageSizesSO;
           
            boolean b;
           
            b = controller.isOk;
           
            string str1 = controller.doResetSearch;
            controller.doResetSearch = 'reset';
           
            controller.selectedProductFamily = 'Competitor CP';
           
            so = controller.productFamilies;
            so = controller.productProducers;
            b = controller.readyForSearch;
           
            PageReference pr;
            pr = controller.changeProductFamily();
           
            b = controller.isCP;
            b = controller.isSE;
           
           
            pr = controller.doSearch();
           
            controller.pageSizeTop = 10;
            pr = controller.rePaginateTop();
           
            controller.pageSizeBottom = 10;
            pr = controller.rePaginateBottom();

            b = controller.canGoBack;
            b = controller.canGoForward;
           
            pr = controller.nextPage();
            pr = controller.prevPage();
           
            integer i;
           
            i = controller.pageNo + controller.totalProducts + controller.totalPages;
           
           
            List<AddCompProduct.ProductData> pd = controller.productData;
            b = controller.hasProductData;
            
            system.debug('----------------------------' + pd.size());   
               
            AddCompProduct.ProductData ppd = new AddCompProduct.ProductData(new Competitor_Product__c(  Active__c=true, Species__c = 'Apple', Name='Seeds COMP ANZ '), controller);       
           
            b = ppd.isCP;
            b = ppd.isSE;
           
            Test.stopTest();
        }
       
    }
   
    private static void createTestUser(){
       
        ID adminProfileID = [SELECT Id FROM Profile WHERE Name = 'System Administrator'].ID;
        localUser= new User(username='localuserforUnitTest@20110308test.com',
                          alias = 'testu',
                          email='localuserforUnitTest@20110308test.com',
                          emailencodingkey='UTF-8',
                          lastname='Syngenta',
                          CommunityNickname ='mahi45678',
                          languagelocalekey='en_US',
                          localesidkey='en_US',                                            
                          profileid = adminProfileID,
                          timezonesidkey='Europe/Berlin'
                         );
        insert localUser;
    }
}

  • November 15, 2012
  • Like
  • 0

Hi,

I have 2 objects witha a parent child relationship. I have a after delete trigger on the child object.

Now i delete the parent object, all its related child records also gets deleted but after delete trigger on the child object does not get called.

I am not understanding why this is happening.

Any information on this would be very useful.

 

Thanks!

The purpose of this trigger is to take a closed won opportunity that is of a certain picklist option 'Subscription_Type__c = 'GradeBeam' and clone it along with the primary contact if there is one.  The reeason is that when we sell a subscription we want to create a renewal oppotunity 1,2, or 3 years down the road.  I have two issues with this code otherwise it works:

 

1. When I close an opportunity it creates 2 clones instead of 1.

2. I have to have a product on the opp before I close otherwise I get "Attempt to de-refference a null object" which is a problem because certain opportunities won't use products, just those who's subscription type is 'GradeBeam'.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
trigger RenewalOppCreate on Opportunity (After update) {
    
  try {

        // List of opportunity IDs
      ID OppId ;
        
        for( opportunity opp: Trigger.New){
        if ((opp.StageName == 'Closed Won') && (opp.Subscription_Type__c == 'GradeBeam')&& (trigger.oldMap.get(opp.id).StageName != 'Closed Won' )){
            OppId = opp.Id;
        }
        }

        
    for( opportunity oldOpp: [SELECT ID, accountId, account.name, Estimated_Renewal_Date__c FROM opportunity WHERE Id = :OppId]){
        
        opportunity renewOpp = New opportunity();
            renewOpp.closedate = oldOpp.Estimated_Renewal_Date__c;
            renewOpp.AccountId = oldOpp.accountId;
            renewOpp.name = oldOpp.account.name + ' Renewal';
            renewOpp.stagename = 'Renewal Scheduled';
            renewOpp.Type = 'Repeat Client';
            insert renewOpp;
            
        
            for( OpportunityContactRole Role: [SELECT ID, ContactId, Role FROM opportunityContactRole WHERE IsPrimary = TRUE AND opportunityId = :OldOpp.ID]){
        
        opportunityContactRole ContactRole = New opportunityContactRole();
            ContactRole.ContactId = Role.ContactId;
            ContactRole.OpportunityId = renewOpp.Id;
            ContactRole.IsPrimary = true;
     
            insert ContactRole;
        }
        }
        
    }catch (Exception e) {Trigger.new[0].addError(e.getMessage());}
}

I have 2 objects, contacts(parent) and custom_1(child).  Im pulling info from both objects and need to display it in a VF table.  So in the controller I have the following query

 

exportGuestList = Database.query(

'select Salutation, FirstName, LastName, Email, Phone, MobilePhone, Company_Name__c, Title, Business_Address__c, Alternate_Address__c, GroupName__c  '+

 

', (SELECT Addres__c FROM Custom_1__r)'+

 

' from Contact where Deceased__c = false AND Id IN(select Custom_2__c '+

 

' from Custom_3__c where Custom_2__c = \''+

whereSQLContactId +

'\') order by LastName ASC LIMIT 5000');

 

I have no problems rendering the contact fields in the table, but when I attempt to render the addres__c field, like so:

 

<apex:pageBlockrendered="{!NOT(ContactsCount==0)}"title="Contacts:">

<apex:pageBlockTablevalue="{!exportGuestList}"var="selecCont">

<apex:columnvalue="{!selecCont.Salutation}"/>

<apex:columnvalue="{!selecCont.LastName}"/>

<apex:columnvalue="{!selecCont.FirstName}"/>

<apex:columnvalue="{!selecCont.Email}"/>

<apex:columnvalue="{!selecCont.Phone}"/>

<apex:columnvalue="{!selecCont.MobilePhone}"/>

<apex:columnvalue="{!selecCont.Company_Name__c}"/>

<apex:columnvalue="{!selecCont.Title}"/>

<apex:columnvalue="{!selecCont.Business_Address__c}"/>

<apex:columnvalue="{!selecCont.Addres__c}"/>

 

I get the following Error:

Error: Invalid field Addres__c for SObject Contact

 

How can I specify in the VF page the proper reference to Custom_1

 

If I append Custom_1__r.  to Addres__c in the table I get:

 

Error: Unknown property 'VisualforceArrayList.Addres__c'
 
Somewhat new to SOQL and apex so i've been pretty stumped on this.
 
Thank you
  • November 08, 2012
  • Like
  • 0

I'm going to risk embarrassing myself here because I know this is something really basic. But I'm just not seeing it.

 

In the following code, when I click Save, I get a DML exception saying that I did not include required fields Account__c and Invoice_Date__c, even though I entered them on the form. I've even tried initializing them in the constructor. But when it gets to the Save method all the properties in the "inv" variable are null.

 

I've also tried this with the format shown in the VF reference guide: "private final Invoice__c inv", using invoice__c in the markup. I've also tried doing this with a public getter method that returns inv. Nothing works.

 

WHY?!

 

//*** Page Markup ***

<apex:page standardController="Invoice__c" extensions="brokenInvoiceController" >
  <apex:form >

    <apex:pageBlock >
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton action="{!save}" value="Save" immediate="true" />
        <apex:commandButton action="{!cancel}" value="Cancel"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection >
        <apex:inputField value="{!inv.Account__c}" label="Account"/>
        <apex:inputField value="{!inv.Invoice_Date__c}" label="Invoice Date"/>
        <apex:inputField value="{!inv.Memo__c}" label="Memo" />
      </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

//*** Controller Extension ***

public with sharing class brokenInvoiceController {

public Invoice__c inv {get;set;}

public brokenInvoiceController(ApexPages.StandardController controller) {
  inv = (Invoice__c)controller.getRecord();
}

 

public PageReference Save() {
  upsert inv;
  return null;
}

public PageReference Cancel() {
  return null;
}
}

Hi Everyone!

 

I'm a newbie to apex code and I'm tryng out a new user-based SOSL query in a visual force page. But  I don't understand the resulting LIST or how to iterate over it using a FOR statement.

 

I perform a SOSL query with the following:

List<List<Myobject>> searchList = [FIND '*00*' IN ALL FIELDS RETURNING Myobject];

 

it seems to work correctly based on the logs from the DeveloperConsole.

 

I get this data back (from DeveloperConsole System.Debug):

USER_DEBUG   [34][DEBUG] Items Found: 1

USER_DEBUG   [34][DEBUG] ITEM: (Myobject:{Id=01tE0000000MKAYIA4}, Myobject:Id=01tE0000000MKAUIA4}, Myobject:Id=01tE0000000MKASIA4}, Myobject:Id=01tE0000000MKATIA4}, Myobject:Id=01tE0000000MKANIA4}, Myobject:Id=01tE0000000MKAQIA4},...)

 

The output was doctored because I didn't spend time to find a text export of the logs,

 

But the SIZE property returns "1" as indicated in the logs and a FOR loop does not work as expected.  It seems I may have a Single List of a multi-valued List (as indicated in the code above).

 

How do I get this to work in FOR loop to iterate over the the returning values?

How can I bypass the List<List<myobject>> to replace it with List<MyObject>?

 

Why do I need to use the List<List<>> syntax at all?  It was the only way I could get it to return the list set.

 

Here is the For Loop:

 

for (List<MyObject> s1 : searchList) {
        System.Debug('Item: ' + s1);
        i++;
  }

 

 

 

 

 

I have a Workflow rule that creates a Task each time a specific type of Lead is created.  I have a custom field in this Task that needs to be populated upon creation but I cannot accomplish this with the Workflow so I am creating a trigger. 

 

I get the following error when I save the trigger

 

Error: Compile Error: unexpected token: '}' at line 5 column 12

 

Here is the trigger

 

trigger PubProductUpdate on Task (before insert){

    for (Task PU : Trigger.new){
        if (PU.RecordTypeId = '012U0000000Z6qBIAS' && PU.Subject = 'Pitch Networks' && PU.Pub_Products__c = null)
            }
    {
    
    PU.Pub_Products__c = 'Pub Opening Pitch';
    }
}

 

I am new to Apex Triggers and not sure where my select criteria goes wrong. 

 

Thanks.

Hi guys,

 

I've searched high and low for some info on what I've done wrong and can't work it out.

 

I basically want to return a list of Prestart_Checklist__c that fall within a given date range and location - this works.

 

Then for each item in the list, I want to present a text box so that a user can update the name of the record. This displays correctly and retrieves the existing data - but the save button seems ineffectual. If I change any values in the inputfields and click save, the page refreshes, but no data is saved.

 

I know I'm missing something simple, but I've wasted too much time on this one to keep hacking away at it, so any suggestions are very welcome.

 

Page:

 

<apex:page action="{!initPage}" standardController="Prestart_Checklist__c" extensions="PSCLEditExtension" >

<apex:form >
    <apex:pageBlock title="Filter results" >
        <apex:pageBlockButtons location="bottom" >
            <apex:commandButton value="Go" reRender="dataTable" />
        </apex:pageBlockButtons>
        <apex:pageBlockSection columns="1">
            <apex:inputField value="{!plantForLocation.Location__c}" />
            <apex:inputField value="{!psclForDate.Week_Ending__c}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

<apex:form >
    <apex:pageBlock title="Prestart Checklists" >
        <apex:pageBlockButtons location="bottom" >
            <apex:commandButton value="Save" action="{!save}" />
        </apex:pageBlockButtons>
        <apex:pageBlockTable id="dataTable" value="{!thisWeeksPSCLs}" var="pscl">
            <apex:column headerValue="Plant Name"> <apex:outputText value="{!pscl.Plant__r.Name}" /></apex:column>
            <apex:column headerValue="Plant Registration"> <apex:outputText value="{!pscl.Plant__r.Registration_Number__c}" /></apex:column>
            <apex:column headerValue="Prestart Checklist Number"><apex:inputField value="{!pscl.Name}" /></apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

 

Controller:

 

public with sharing class PSCLEditExtension {
    
    public Prestart_Checklist__c psclForDate{get; set;}
    public Plant__c plantForLocation{get; set;}
    
    public List<Plant__c> listPlant {
        get {
            return [select Id, Name from Plant__c];
        }
    }
    
    public List<Prestart_Checklist__c> listPSCL{get; set;}
    
    public List<Prestart_Checklist__c> thisWeeksPSCLs{
    	get {
	    	return [select Id, Name, Plant__r.Name, Plant__r.Registration_Number__c 
	                from Prestart_Checklist__c 
	    	        where Week_Ending__c = :psclForDate.Week_Ending__c 
	    	        and Plant__r.Location__c = :plantForLocation.Location__c];
} } } public PSCLEditExtension(ApexPages.StandardController controller) { psclForDate = new Prestart_Checklist__c(Week_Ending__c = Date.today().toStartOfWeek()); plantForLocation = new Plant__c(); } public void initPage() { } }

 

Hello,

I'm getting an error when running a test on the follow piece of code... the underlined piece is where the error is coming from, any ideas on how to correct this?

 

System.DmlException: Update failed. First exception on row 0 with id a07c0000000fbUFAAY; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Trade: execution of BeforeUpdate caused by: line 17, column 1: Illegal empty right operand for operator '<=' in query 'select COUNT(id), WhoId from Task '.: []

 

Set<Date> PStart = new Set<Date>();
    for(Transaction__c t:trigger.new)
        PStart.add(t.Trade_Period_Start__c);
        
    Set<Date> PEnd = new Set<Date>();
    for(Transaction__c t:trigger.new)
        PStart.add(t.Trade_Date__c);
        
    Set<Id> cid = new Set<Id>();
    for(Transaction__c t:trigger.new)
        cid.add(t.rep__c);

    Map<String,Integer> callCountMap = new Map<String,Integer>();
        for(AggregateResult r:[select COUNT(id), WhoId from Task where Whoid in :cid AND (Type = 'Cold Call' OR Type = 'Inbound Call' OR Type = 'Outbound Call') AND Status = 'Completed' AND isDeleted = False AND (Date_Completed__c >=: PStart AND Date_Completed__c <=: PEnd) GROUP BY WhoId LIMIT 100 ALL ROWS])
            callCountMap.put(String.valueof(r.get('WhoId')),Integer.valueof(r.get('expr0')));

 

I'm trying to write a unit test for a trigger that captures the OwnerID of an Opportunity, and then populates a "Owner Details" field (giving us access to their entire user record) and a "Sales Manager" field (which is the user's manager).

 

I'm at 73% coverage, but the part that is not covered is the after update when the Opportunity Owner has changed. I've written into my test a scenario when the Opp Owner changes, but I'm getting the following error message:

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CopyOwnerInformation: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006S0000006jI1iIAE; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CopyOwnerInformation: maximum trigger depth exceeded Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i] Opportunity trigger event AfterUpdate for [006S0000006jI1i]: [] Trigger.CopyOwnerInformation: line 40, column 1: []

 

Here is the relevant code from my trigger. This is the part that I am trying to cover:

 

//Insert new owner details ID if it has changed
if(opp.Owner_Details__c == null || (opp.OwnerId != oldopp.OwnerID)){
List<Opportunity> OppsWithNewOwner = [SELECT ID, OwnerID, Owner_Details__c FROM Opportunity WHERE id in:trigger.new];

for (Integer i=0; i<OppsWithNewOwner.size(); i++){                                      
    OppswithNewOwner[i].Owner_Details__c = OppsWithNewOwner[i].OwnerID;}
    
    update OppsWithNewOwner;

    }

 

And here is my test class:

 

@isTest
private class Test_CopyOwnerInformation{
    static testMethod void CopyOwnerInformation(){
    
//set up test records
        
User user1 = new User();
        user1.firstname = 'Test User 1 First Name';
        user1.lastname = 'Test User 1 Last Name';
        user1.alias = 'user1';
        user1.email = 'testuser@unittest.com';
        user1.EmailEncodingKey = 'ISO-8859-1';
        user1.username = 'testuser1@unittest.com';
        user1.TimeZoneSidKey = 'America/Chicago';
        user1.LocaleSidKey = 'en_US';
        user1.ProfileId = '00e70000000sP2v';
        user1.LanguageLocaleKey = 'en_US';
        insert user1;
        
User manager2 = new User();
        manager2.firstname = 'Test Manager 2 First Name';
        manager2.lastname = 'Test Manager 2 Last Name';
        manager2.alias = 'mgr2';
        manager2.email = 'testmanager@unittest.com';
        manager2.EmailEncodingKey = 'ISO-8859-1';
        manager2.username = 'testmanager2@unittest.com';
        manager2.TimeZoneSidKey = 'America/Chicago';
        manager2.LocaleSidKey = 'en_US';
        manager2.ProfileId = '00e70000000sP2v';
        manager2.LanguageLocaleKey = 'en_US';
        insert manager2;
        
User user2 = new User();
        user2.firstname = 'Test User 2 First Name';
        user2.lastname = 'Test User 2 Last Name';
        user2.alias = 'user2';
        user2.email = 'testuser@unittest.com';
        user2.EmailEncodingKey = 'ISO-8859-1';
        user2.username = 'testuser2@unittest.com';
        user2.manager = manager2;
        user2.TimeZoneSidKey = 'America/Chicago';
        user2.LocaleSidKey = 'en_US';
        user2.ProfileId = '00e70000000sP2v';
        user2.LanguageLocaleKey = 'en_US';
        insert user2;
  
Account account = new Account();
        account.Name = 'Test Account';
        account.OwnerID = user1.id;
        account.web_site__c = 'test.com';
        account.industry = 'Entertainment';
        account.type = 'Advertiser';
        insert account;
        
Opportunity opportunity = new Opportunity();
        opportunity.AccountId = account.Id;
        opportunity.OwnerID = account.OwnerId;
        opportunity.Name = 'Test Opportunity';
        opportunity.StageName = 'Active';
        opportunity.CloseDate = System.today();
        opportunity.Amount = 1000.00;
        opportunity.Type = 'New Client';
        
//test  
    test.startTest();     
        insert opportunity;
    
//Validate that the Owner Details field was updated.
    opportunity = [SELECT OwnerId, Owner_Details__c, Owner_Details__r.ManagerID, SalesManager__c FROM Opportunity WHERE id = :opportunity.id];
    System.assertEquals(opportunity.OwnerId, opportunity.Owner_Details__c);
    System.assertEquals(opportunity.SalesManager__c, Opportunity.Owner_Details__r.ManagerID);

//Test that the Owner Details changes with an Opp Owner Change
   
        opportunity.OwnerId = user2.ID;
        update opportunity;
     test.stopTest();

//Validate that the Owner Details and Manager fields were updated.
    opportunity = [SELECT OwnerID, Owner_Details__c, Owner_Details__r.ManagerID, SalesManager__c FROM Opportunity WHERE id = :opportunity.id];
    System.assertEquals(opportunity.Owner_Details__c, user2.Id);
    System.assertEquals(opportunity.SalesManager__c, user2.Manager.Id);
    }
}

 Thank you for the help!

 

Hi all:

 

I'm a relative newb. I'm building an integration with salesforce.com via the SOAP API. I've reached a sticking point.  There is a report that  I need to access via the API.  I understand I can't access this directly, but the preferred approach is to mimic the SOQL that the report would be running, and generate the same data set that way.  

 

This seems straight forward, but I can't seem to make my SOQL get the same number of results as the report in salesforce.com.  Attached is a screen capture from the report page, as well as the SOQL I'm trying to use to generate the same data set.

 

 

 

 

 

SELECT Count(Id), (SELECT Contact.Name FROM Account.Contacts WHERE Contact.MaRS_Contact_Relationship__c INCLUDES ('Advisory Services Primary Contact') AND Contact.Inactive_Person_left_company__c = false) FROM Account WHERE MaRS_Company_Relationships__c INCLUDES ('Active VG Client', 'High Potential Client', 'SiG Client')

 

Can anyone see how these differ?  Or do you know how, in general, to get the SOQL that the report is executing?

This is my first trigger and I only have an admin background so I’m stuck early on. I have Master Opportunities that have children opportunities off of them. If the master opportunity is marked Closed Lost then the Children all need to be updated to a stage of Closed Lost as well. I know in English what I want to do:

 

I Need an "After Update" trigger.  
I Need to take the id of the master Opportunity and use it to query for a list of child Opportunities.

I Need to Loop thru the children, to see if the Stage Value of the child is not “Closed Lost”.
If it is not “Closed Lost” I need to add each child to a list for updating.
Finally I need to update the Stage on the list of Children once I’ve checked all of them. 

 

I have a start...

trigger updateChildOpportunity on Opportunity (After update) {

and now I’m stuck :-(

I have an app that is getting a System.NullPointerException: Attempt to de-reference a null object at a customer account.  Does this error log any information about the error that I can ask the customer to provide - if so how does one get to the info?