• Gator
  • NEWBIE
  • 0 Points
  • Member since 2008

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

I'm hitting the system null pointer problem on line 5 when I try to delete a RepSplit__c record:

 

 

line 5 starts here: 

---------------------

for(RepSplit__c oppp : Trigger.New)
{
obJoppp.add(oppp.Opportunity__c);
}

 

 

 

Full code:

---------------------

trigger createnewRecordsUnderOpp on RepSplit__c (after insert, after update, after delete)

{

 

// locates the related Opportunity and deletes all RepRevShare records that are related to it
Set<Id> obJoppp = new Set<Id>();
for(RepSplit__c oppp : Trigger.New)
{
obJoppp.add(oppp.Opportunity__c);
}
List<RepRevShare__c> objecRepRevShare = [select id from RepRevShare__c where Opportunity__c in : obJoppp];
delete objecRepRevShare;

 

// locates the related Opportunity and creates a new set of RepRevShare records to be related to it
Set<Id> obJopp = new Set<Id>();
for(RepSplit__c opp : Trigger.New)
{
obJopp.add(opp.Opportunity__c);
}

List<RepRevShare__c> objRepRevShare = new List<RepRevShare__c>();
List<RepSplit__c> objRepsplit = [select id,Name,Opportunity__c, SplitPercent__c, Rep__c from RepSplit__c where Opportunity__c in : obJopp];
List<OppPayment__c> objOppPayment = [select id, Name, Opportunity__c, Opp_Product__c, Date__c, Amount__c, Booked__c from OppPayment__c where Opportunity__c in : obJopp];

for(RepSplit__c objRepSp : objRepsplit){
for(OppPayment__c objOppPay : objOppPayment){
RepRevShare__c objRepRevSharel = new RepRevShare__c();
objRepRevSharel.Name = objRepSp.Name + objOppPay.Name ;
objRepRevSharel.Opportunity__c = objRepSp.Opportunity__c ;
objRepRevSharel.Percent__c = objRepSp.SplitPercent__c ;
objRepRevSharel.Rep__c = objRepSp.Rep__c ;
objRepRevSharel.Date__c = objOppPay.Date__c ;
objRepRevSharel.Booked__c = objOppPay.Booked__c ;
objRepRevSharel.OppPayAmount__c = objOppPay.Amount__c ;
objRepRevShare.add(objRepRevSharel);
}}

insert(objRepRevShare);
}

  • February 18, 2013
  • Like
  • 0

I have two custom objects under the Opportunity object and I'd like to make a trigger that creates a third set of custom object records.

 

Custom object one is 'RepSplit__c': contains a Sales Rep (user lookup id) and Percentage Split (percentage)

Custom object two is 'OppPayment__c': contains a Date and amount of money received (currency) and amount of money initially expected (currency)

Third custom object titled 'RepRevShare__c' -- Opportunity, Percentage, Expected Amount, Actual Amount, Date, Amount of Money Received * Percentage (formula), 

 

I want to have RepRevShare records be the combination of the other two objects, so if I have RepSplit1,2,and 3...and OppPayments A,B... then I want to trigger creation of six records:

RepRevShare1A, 1B, 2A, 2B, 3A, and 3B

 

All this to have matrix reporting where my Reps are on the Y axis and Months are on the X axis, with money in the middle!

 

 

 

So here goes with my little programming knowledge...

 

My thinking was I need the following actions:

before insert,update,delete of a RepSplit or an OppPayment --   clear/delete all RepRevShare records under the related Opportunity

after insert,update,delete pf a RepSplit or an OppPayment -- create all new RepRevShare records

 

Is this possible?  I've been working my way through coding bits and pieces but my guess is there is a far easier way to code this.

 

 

  • February 13, 2013
  • Like
  • 0

End goal is to have a report type that includes the following data-

- Opportunity info

- info from a custom object underneath the opportunity called CustomObjectUnderOpportunity (master-detail relationship with opportunity)

- info from all OpportunityLineItemSchedules under that opportunity

 

 

I believe I need a trigger to make a new object -- Let's call it CustomLineItemSchedule -- that can create a record for each combination.

 ie: 2 custom object records under opp, 3 opportunitylineitemschedules = 6 new link objects created

 

Problem Part 1:

I'm trying to extract the Revenue and ScheduleDate fields from any OpportunityLineItemSchedule record that is created/changed/deleted and drop those values into two fields in CustomLineItemSchedule.

 

I'm aware that you cannot run a trigger directly off of the OpportunityLineItemSchedule, but I believe there is a way to do this by comparing the LastModifiedDate of each OpportunityLineItemSchedule record against the OpportunityLineItem.LastModifiedDate.

 

Part 2: 

Trigger does some combinatorics to create 2*3= 6 new CustomLineItemSchedule records rather than just 3 (one for each opportunitylineitemschedule).  Trigger would have to put a couple fields from the CustomObjectUnderOpportunity record into the new object.

 

 

This allows me to create an 'Opportunity and CustomLineItemSchedule' report with all the fields I need.

 

Does anyone have any suggestions?  GREATLY appreciated. Hope this was explained well...

  • January 18, 2013
  • Like
  • 0

I'm hitting the system null pointer problem on line 5 when I try to delete a RepSplit__c record:

 

 

line 5 starts here: 

---------------------

for(RepSplit__c oppp : Trigger.New)
{
obJoppp.add(oppp.Opportunity__c);
}

 

 

 

Full code:

---------------------

trigger createnewRecordsUnderOpp on RepSplit__c (after insert, after update, after delete)

{

 

// locates the related Opportunity and deletes all RepRevShare records that are related to it
Set<Id> obJoppp = new Set<Id>();
for(RepSplit__c oppp : Trigger.New)
{
obJoppp.add(oppp.Opportunity__c);
}
List<RepRevShare__c> objecRepRevShare = [select id from RepRevShare__c where Opportunity__c in : obJoppp];
delete objecRepRevShare;

 

// locates the related Opportunity and creates a new set of RepRevShare records to be related to it
Set<Id> obJopp = new Set<Id>();
for(RepSplit__c opp : Trigger.New)
{
obJopp.add(opp.Opportunity__c);
}

List<RepRevShare__c> objRepRevShare = new List<RepRevShare__c>();
List<RepSplit__c> objRepsplit = [select id,Name,Opportunity__c, SplitPercent__c, Rep__c from RepSplit__c where Opportunity__c in : obJopp];
List<OppPayment__c> objOppPayment = [select id, Name, Opportunity__c, Opp_Product__c, Date__c, Amount__c, Booked__c from OppPayment__c where Opportunity__c in : obJopp];

for(RepSplit__c objRepSp : objRepsplit){
for(OppPayment__c objOppPay : objOppPayment){
RepRevShare__c objRepRevSharel = new RepRevShare__c();
objRepRevSharel.Name = objRepSp.Name + objOppPay.Name ;
objRepRevSharel.Opportunity__c = objRepSp.Opportunity__c ;
objRepRevSharel.Percent__c = objRepSp.SplitPercent__c ;
objRepRevSharel.Rep__c = objRepSp.Rep__c ;
objRepRevSharel.Date__c = objOppPay.Date__c ;
objRepRevSharel.Booked__c = objOppPay.Booked__c ;
objRepRevSharel.OppPayAmount__c = objOppPay.Amount__c ;
objRepRevShare.add(objRepRevSharel);
}}

insert(objRepRevShare);
}

  • February 18, 2013
  • Like
  • 0

I have two custom objects under the Opportunity object and I'd like to make a trigger that creates a third set of custom object records.

 

Custom object one is 'RepSplit__c': contains a Sales Rep (user lookup id) and Percentage Split (percentage)

Custom object two is 'OppPayment__c': contains a Date and amount of money received (currency) and amount of money initially expected (currency)

Third custom object titled 'RepRevShare__c' -- Opportunity, Percentage, Expected Amount, Actual Amount, Date, Amount of Money Received * Percentage (formula), 

 

I want to have RepRevShare records be the combination of the other two objects, so if I have RepSplit1,2,and 3...and OppPayments A,B... then I want to trigger creation of six records:

RepRevShare1A, 1B, 2A, 2B, 3A, and 3B

 

All this to have matrix reporting where my Reps are on the Y axis and Months are on the X axis, with money in the middle!

 

 

 

So here goes with my little programming knowledge...

 

My thinking was I need the following actions:

before insert,update,delete of a RepSplit or an OppPayment --   clear/delete all RepRevShare records under the related Opportunity

after insert,update,delete pf a RepSplit or an OppPayment -- create all new RepRevShare records

 

Is this possible?  I've been working my way through coding bits and pieces but my guess is there is a far easier way to code this.

 

 

  • February 13, 2013
  • Like
  • 0

End goal is to have a report type that includes the following data-

- Opportunity info

- info from a custom object underneath the opportunity called CustomObjectUnderOpportunity (master-detail relationship with opportunity)

- info from all OpportunityLineItemSchedules under that opportunity

 

 

I believe I need a trigger to make a new object -- Let's call it CustomLineItemSchedule -- that can create a record for each combination.

 ie: 2 custom object records under opp, 3 opportunitylineitemschedules = 6 new link objects created

 

Problem Part 1:

I'm trying to extract the Revenue and ScheduleDate fields from any OpportunityLineItemSchedule record that is created/changed/deleted and drop those values into two fields in CustomLineItemSchedule.

 

I'm aware that you cannot run a trigger directly off of the OpportunityLineItemSchedule, but I believe there is a way to do this by comparing the LastModifiedDate of each OpportunityLineItemSchedule record against the OpportunityLineItem.LastModifiedDate.

 

Part 2: 

Trigger does some combinatorics to create 2*3= 6 new CustomLineItemSchedule records rather than just 3 (one for each opportunitylineitemschedule).  Trigger would have to put a couple fields from the CustomObjectUnderOpportunity record into the new object.

 

 

This allows me to create an 'Opportunity and CustomLineItemSchedule' report with all the fields I need.

 

Does anyone have any suggestions?  GREATLY appreciated. Hope this was explained well...

  • January 18, 2013
  • Like
  • 0