• Adam08
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 11
    Replies

Hi,

 

I have a trigger that updates a field in a custom object (record detail).

The trigger works fine (based on the file size being greater than 0 but i'm trying to add in another condition based on the file type being an excel file.

 

trigger updatemdf on Attachment (after insert) 
            {
                        List<MDF__c> co = [select id, Leads_uploaded__c from mdf__c where id =: Trigger.New[0].ParentId];
                        if (co.Name.endsWith('.xls') && (co.size()>0))
                        {
                                    co[0].leads_uploaded__c = true;
                                    update co;
                        }                                                                    
            }

 error messgae i'm getting at line 4 is:

'Save error: Initial term of field expression must be a concrete SObject: LIST<MDF__c> 

 

Any ideas?

 

Thanks

  • September 07, 2011
  • Like
  • 0

Hi,

 

we have some code that triggers the auto submission of a custom object record  for approval.

we want this to trigger after insert or update where a particular chackbox is ticked which could be on insert or after an update.

 

however we are getting the errors:

- CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:

- System.NullPointerException: Attempt to de-reference a null object

 

here is the code:

 

trigger MDFSubmitForApproval on MDF__c (after insert, after update) {


for (Integer i = 0; i < trigger.new.size(); i++) 
{
   if(Trigger.old[i].Submitted__c != true && Trigger.new[i].Submitted__c == true)
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(Trigger.new[i].id);
}
}
}

 class:

@isTest
private class TestMDFSubmitForApproval {
 
    static testMethod void testApprovalSuccess() {
 
        MDF__c mdf = new MDF__c();
        mdf.Name = 'Test';
        mdf.Account_id__c = '00120000001Sqvv';
        // insert the new MDF
        insert mdf;
        mdf.Submitted__c = true;
        update mdf; 
        
        // ensure that the opp was submitted for approval
        List<ProcessInstance> processInstances = [select Id, Status from ProcessInstance where TargetObjectId = :mdf.id];
    System.assertEquals(processInstances.size(),1);
 
    }
 
}

 any ideas?

 

Thanks

  • September 02, 2011
  • Like
  • 0

Hi,

 

I have set up a trigger that automatically submits a custom object for approval.

Currently this triggers on insert of new records, but I need to change this to trigger after a checkbox is updated, which can happen upon insert or afteran update. this is the only criteria for the trigger.

 

Appreciate any help.

 

here is my trigger:

 

trigger MDFSubmitForApproval on MDF__c (after insert) {

 

for

(MDF__c a : trigger.new) {

 

Approval.ProcessSubmitRequest app = newApproval.ProcessSubmitRequest();

app.setObjectId(a.id);

 

Approval.ProcessResult result = Approval.process(app);

 

}

}

}

 

 

  • September 01, 2011
  • Like
  • 0

Hi,

 

I'm new to Apex code and wondered if someone could help me with the following scenario:

 

- We have sales guys who work globally on opportunities involving partners. It's hard for us to define security setting for these individuals without giving them access to all our data.

 

- We need to automatically update the opportunity sales team based on the partner chosen within the related list that is selected in the opportunity.

I have a list of which sales guys look after each partner opps so I assume this would need to be related to the account id for the partner orgs.

 

As I say I'm new to Apex, so am unsure if this is achievable?

 

Many thanks.

  • April 13, 2011
  • Like
  • 0

Hi,

 

I have a trigger that updates a field in a custom object (record detail).

The trigger works fine (based on the file size being greater than 0 but i'm trying to add in another condition based on the file type being an excel file.

 

trigger updatemdf on Attachment (after insert) 
            {
                        List<MDF__c> co = [select id, Leads_uploaded__c from mdf__c where id =: Trigger.New[0].ParentId];
                        if (co.Name.endsWith('.xls') && (co.size()>0))
                        {
                                    co[0].leads_uploaded__c = true;
                                    update co;
                        }                                                                    
            }

 error messgae i'm getting at line 4 is:

'Save error: Initial term of field expression must be a concrete SObject: LIST<MDF__c> 

 

Any ideas?

 

Thanks

  • September 07, 2011
  • Like
  • 0

Hi,

 

we have some code that triggers the auto submission of a custom object record  for approval.

we want this to trigger after insert or update where a particular chackbox is ticked which could be on insert or after an update.

 

however we are getting the errors:

- CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY:

- System.NullPointerException: Attempt to de-reference a null object

 

here is the code:

 

trigger MDFSubmitForApproval on MDF__c (after insert, after update) {


for (Integer i = 0; i < trigger.new.size(); i++) 
{
   if(Trigger.old[i].Submitted__c != true && Trigger.new[i].Submitted__c == true)
{
Approval.ProcessSubmitRequest app = new Approval.ProcessSubmitRequest();
app.setObjectId(Trigger.new[i].id);
}
}
}

 class:

@isTest
private class TestMDFSubmitForApproval {
 
    static testMethod void testApprovalSuccess() {
 
        MDF__c mdf = new MDF__c();
        mdf.Name = 'Test';
        mdf.Account_id__c = '00120000001Sqvv';
        // insert the new MDF
        insert mdf;
        mdf.Submitted__c = true;
        update mdf; 
        
        // ensure that the opp was submitted for approval
        List<ProcessInstance> processInstances = [select Id, Status from ProcessInstance where TargetObjectId = :mdf.id];
    System.assertEquals(processInstances.size(),1);
 
    }
 
}

 any ideas?

 

Thanks

  • September 02, 2011
  • Like
  • 0

Hi,

 

I have set up a trigger that automatically submits a custom object for approval.

Currently this triggers on insert of new records, but I need to change this to trigger after a checkbox is updated, which can happen upon insert or afteran update. this is the only criteria for the trigger.

 

Appreciate any help.

 

here is my trigger:

 

trigger MDFSubmitForApproval on MDF__c (after insert) {

 

for

(MDF__c a : trigger.new) {

 

Approval.ProcessSubmitRequest app = newApproval.ProcessSubmitRequest();

app.setObjectId(a.id);

 

Approval.ProcessResult result = Approval.process(app);

 

}

}

}

 

 

  • September 01, 2011
  • Like
  • 0

Hi,

 

I'm new to Apex code and wondered if someone could help me with the following scenario:

 

- We have sales guys who work globally on opportunities involving partners. It's hard for us to define security setting for these individuals without giving them access to all our data.

 

- We need to automatically update the opportunity sales team based on the partner chosen within the related list that is selected in the opportunity.

I have a list of which sales guys look after each partner opps so I assume this would need to be related to the account id for the partner orgs.

 

As I say I'm new to Apex, so am unsure if this is achievable?

 

Many thanks.

  • April 13, 2011
  • Like
  • 0