-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
5Questions
-
7Replies
Chart from 2 objects
Hi all!
We use the revunue scheduler to track our customer installments (works like a charm) and an custom object 'Payments__c' where payment detaisl are entered.
Now I want to create 1 chart with bucketed date values (per month) on x-asis and includes both the expected payments (from OppertunityProduct object) and the actual payments on y-axis as 2 seperate lines/bars. Does anyonde have an idea how to resolve?
See report from revenue schedule below:
We use the revunue scheduler to track our customer installments (works like a charm) and an custom object 'Payments__c' where payment detaisl are entered.
Now I want to create 1 chart with bucketed date values (per month) on x-asis and includes both the expected payments (from OppertunityProduct object) and the actual payments on y-axis as 2 seperate lines/bars. Does anyonde have an idea how to resolve?
See report from revenue schedule below:
-
- Thijs Faber
- October 21, 2017
- Like
- 0
- Continue reading or reply
Line Product does not invoke Apax trigger, do I need Scheduled Batche updates?
Hi all,
I have some apax trigger in order to roll up some fields from the Oppertunity Product object -> Oppertunity object -> Account object -> Account group (custom) object. Where standard roll-up functionality did not work, the trigger all work fine.
In the Oppertunity Product object, I have a field that is calculated: it is the sum of the revenue installments up unitil today. This field is update auomatially daily, however, this update does not invoke my apex trigger, is that correct? If yes, would the scheduled batch class in apax be the best solution to fix this?
Much appriciated!,
Thijs
I have some apax trigger in order to roll up some fields from the Oppertunity Product object -> Oppertunity object -> Account object -> Account group (custom) object. Where standard roll-up functionality did not work, the trigger all work fine.
In the Oppertunity Product object, I have a field that is calculated: it is the sum of the revenue installments up unitil today. This field is update auomatially daily, however, this update does not invoke my apex trigger, is that correct? If yes, would the scheduled batch class in apax be the best solution to fix this?
Much appriciated!,
Thijs
-
- Thijs Faber
- August 25, 2017
- Like
- 0
- Continue reading or reply
Apex trigger Test class
Hi there,
I got the feeling that I'm almost there. My test class shows a disappointing 0% coverage. What am I doing wrong?
This is my trigger (works in my sandbox, aside from an unintended modulation to my corporate currency <- solved with custom formula field):
This is my (under performing) test class:
The help so far has already been awesome, thanks again you all!
Thijs
I got the feeling that I'm almost there. My test class shows a disappointing 0% coverage. What am I doing wrong?
This is my trigger (works in my sandbox, aside from an unintended modulation to my corporate currency <- solved with custom formula field):
trigger TotalAmountTrigger on Account (after insert, after update, after delete, after undelete) { Set<Id> accountIds = new Set<Id>(); for(Account c: Trigger.isDelete? Trigger.old : Trigger.new){ if(c.GroupName__c != null) { accountIds.add(c.GroupName__c ); } } List<CustomerGroups__c> accList = new List<CustomerGroups__c>(); for(AggregateResult currentAggResult:[SELECT GroupName__c accId, SUM(Customer_Loan_Amount__c ) sumAmt FROM Account WHERE GroupName__c in:accountIds GROUP BY GroupName__c ]) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = (Id)currentAggResult.get('accId'); acc.Customer_Group_OLB__c = (decimal)currentAggResult.get('sumAmt'); accList.add(acc); accountIds.remove((Id)currentAggResult.get('accId')); } for(Id currAccId : accountIds) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = currAccId; acc.Customer_Group_OLB__c = null; accList.add(acc); } update accList; }
This is my (under performing) test class:
@isTest public class TestTrigger1 { static testMethod void testMethod1() { CustomerGroups__c p = new CustomerGroups__c (); p.Name='testgroup'; insert p; Account c = new Account(GroupName__c = p.id); c.Name='CustomerTest'; c.Date_of_Sale__c=date.today(); c.Invoice_No__c='123'; c.GroupName__c='Rotterdam Group'; c.CurrencyIsoCode ='ZAR'; insert c; Opportunity g = new Opportunity (AccountId = c.id); g.Name='OpptyTest'; g.CloseDate=date.today(); g.CurrencyIsoCode ='ZAR'; g.StageName='Closed Won'; insert g; OpportunityLineItem b = new OpportunityLineItem (OpportunityId = g.id); b.Owed_so_far__c=100; b.Paid_so_far__c=5; b.Quantity=1; b.TotalPrice=1000; insert b; Product2 f = new Product2 (Id = b.id); f.Name='ACE1 R1,080 9Month Credit'; f.CurrencyIsoCode='ZAR'; insert f; } }
The help so far has already been awesome, thanks again you all!
Thijs
-
- Thijs Faber
- June 01, 2017
- Like
- 0
- Continue reading or reply
Apex trigger - unintended currency modulation
Hi all,
So my first trigger seemed to work in my sandbox. In my organisation we have multiple currencies:
1. EUR for group reporting (corporate currency)
2. ZAR at our first local entity (more foreign entities will added later).
When I used the trigger (see below) it rolls up the amounts but converts the ZAR amount into the EUR amount unintended (but does use the AR prefix). Simply multiplying by the conversion rate wuld lead to differences due to rounding. Is there an elegant solution for this?
Thanks in advance!
Kind regards,
Thijs
So my first trigger seemed to work in my sandbox. In my organisation we have multiple currencies:
1. EUR for group reporting (corporate currency)
2. ZAR at our first local entity (more foreign entities will added later).
When I used the trigger (see below) it rolls up the amounts but converts the ZAR amount into the EUR amount unintended (but does use the AR prefix). Simply multiplying by the conversion rate wuld lead to differences due to rounding. Is there an elegant solution for this?
Thanks in advance!
trigger TotalAmountTrigger on Account (after insert, after update, after delete, after undelete) { Set<Id> accountIds = new Set<Id>(); for(Account c: Trigger.isDelete? Trigger.old : Trigger.new){ if(c.GroupName__c != null) { accountIds.add(c.GroupName__c ); } } List<CustomerGroups__c> accList = new List<CustomerGroups__c>(); for(AggregateResult currentAggResult:[SELECT GroupName__c accId, SUM(Customer_Loan_Amount__c ) sumAmt FROM Account WHERE GroupName__c in:accountIds GROUP BY GroupName__c ]) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = (Id)currentAggResult.get('accId'); acc.Customer_Group_OLB__c = (decimal)currentAggResult.get('sumAmt'); accList.add(acc); accountIds.remove((Id)currentAggResult.get('accId')); } for(Id currAccId : accountIds) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = currAccId; acc.Customer_Group_OLB__c = null; accList.add(acc); } update accList; }
Kind regards,
Thijs
-
- Thijs Faber
- May 31, 2017
- Like
- 0
- Continue reading or reply
Apex trigger - faulty adjustment
Hi there,
For the last days I have been struggeling with Apex Triggers, I need to roll up a currency field from the (standard) 'Account' object to the custom 'CustomerGroups__c' object. I'd prefer avoiding Apex, but Sales Force does not allow me to make a parent for the Account object.
From the child 'Account', I'd like to roll up the currency field "Customer_OLB__c" and summarize those amounts in the parents object 'CustomerGroups__c' field 'Customer_Group_OLB__c'.
Adjusting one of the previously provided examples has lead me to to following code, where I get an problem in line 2: "unexpected token: ':' "
Kind regards,
Thijs
For the last days I have been struggeling with Apex Triggers, I need to roll up a currency field from the (standard) 'Account' object to the custom 'CustomerGroups__c' object. I'd prefer avoiding Apex, but Sales Force does not allow me to make a parent for the Account object.
From the child 'Account', I'd like to roll up the currency field "Customer_OLB__c" and summarize those amounts in the parents object 'CustomerGroups__c' field 'Customer_Group_OLB__c'.
Adjusting one of the previously provided examples has lead me to to following code, where I get an problem in line 2: "unexpected token: ':' "
trigger UpdateAccount on Account (after insert, after update, after delete, after undelete) { Map<Id,CustomerGroups__c> updateCustomerGroups = new Map<Id,CustomerGroups__c>; Set<Id> updateCustomerGroupsIds = new Map<Id,CustomerGroups__c>(); if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete) for (Account account:Trigger.new) updateCustomerGroupsIds.add(account.CustomerGroups__c_Name); if(Trigger.isUpdate || Trigger.isDelete) for (Account account:Trigger.old) updateCustomerGroupsIds.add(account.CustomerGroups__c_Name); updateCustomerGroupsIds.remove(null); for(Id CustomerGroupsId:updateCustomerGroupsIds) updateCustomerGroupsIds.put (CustomerGroupsId,new CustomerGroups (id=CustomerGroupsId,Accounts_Count=0); for Account account:[select id,CustomerGroups__c_Name from account where CustomerGroups__c_Name in :updateCustomerGroupsIds]) updateCustomerGroups.get (account.CustomerGroups__c_Name).Accounts_Count++; Database.update(updateCustomerGroups.values()); ) }Any help would be much appreciated!
Kind regards,
Thijs
-
- Thijs Faber
- May 30, 2017
- Like
- 0
- Continue reading or reply
Apex trigger Test class
Hi there,
I got the feeling that I'm almost there. My test class shows a disappointing 0% coverage. What am I doing wrong?
This is my trigger (works in my sandbox, aside from an unintended modulation to my corporate currency <- solved with custom formula field):
This is my (under performing) test class:
The help so far has already been awesome, thanks again you all!
Thijs
I got the feeling that I'm almost there. My test class shows a disappointing 0% coverage. What am I doing wrong?
This is my trigger (works in my sandbox, aside from an unintended modulation to my corporate currency <- solved with custom formula field):
trigger TotalAmountTrigger on Account (after insert, after update, after delete, after undelete) { Set<Id> accountIds = new Set<Id>(); for(Account c: Trigger.isDelete? Trigger.old : Trigger.new){ if(c.GroupName__c != null) { accountIds.add(c.GroupName__c ); } } List<CustomerGroups__c> accList = new List<CustomerGroups__c>(); for(AggregateResult currentAggResult:[SELECT GroupName__c accId, SUM(Customer_Loan_Amount__c ) sumAmt FROM Account WHERE GroupName__c in:accountIds GROUP BY GroupName__c ]) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = (Id)currentAggResult.get('accId'); acc.Customer_Group_OLB__c = (decimal)currentAggResult.get('sumAmt'); accList.add(acc); accountIds.remove((Id)currentAggResult.get('accId')); } for(Id currAccId : accountIds) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = currAccId; acc.Customer_Group_OLB__c = null; accList.add(acc); } update accList; }
This is my (under performing) test class:
@isTest public class TestTrigger1 { static testMethod void testMethod1() { CustomerGroups__c p = new CustomerGroups__c (); p.Name='testgroup'; insert p; Account c = new Account(GroupName__c = p.id); c.Name='CustomerTest'; c.Date_of_Sale__c=date.today(); c.Invoice_No__c='123'; c.GroupName__c='Rotterdam Group'; c.CurrencyIsoCode ='ZAR'; insert c; Opportunity g = new Opportunity (AccountId = c.id); g.Name='OpptyTest'; g.CloseDate=date.today(); g.CurrencyIsoCode ='ZAR'; g.StageName='Closed Won'; insert g; OpportunityLineItem b = new OpportunityLineItem (OpportunityId = g.id); b.Owed_so_far__c=100; b.Paid_so_far__c=5; b.Quantity=1; b.TotalPrice=1000; insert b; Product2 f = new Product2 (Id = b.id); f.Name='ACE1 R1,080 9Month Credit'; f.CurrencyIsoCode='ZAR'; insert f; } }
The help so far has already been awesome, thanks again you all!
Thijs
- Thijs Faber
- June 01, 2017
- Like
- 0
- Continue reading or reply
Apex trigger - unintended currency modulation
Hi all,
So my first trigger seemed to work in my sandbox. In my organisation we have multiple currencies:
1. EUR for group reporting (corporate currency)
2. ZAR at our first local entity (more foreign entities will added later).
When I used the trigger (see below) it rolls up the amounts but converts the ZAR amount into the EUR amount unintended (but does use the AR prefix). Simply multiplying by the conversion rate wuld lead to differences due to rounding. Is there an elegant solution for this?
Thanks in advance!
Kind regards,
Thijs
So my first trigger seemed to work in my sandbox. In my organisation we have multiple currencies:
1. EUR for group reporting (corporate currency)
2. ZAR at our first local entity (more foreign entities will added later).
When I used the trigger (see below) it rolls up the amounts but converts the ZAR amount into the EUR amount unintended (but does use the AR prefix). Simply multiplying by the conversion rate wuld lead to differences due to rounding. Is there an elegant solution for this?
Thanks in advance!
trigger TotalAmountTrigger on Account (after insert, after update, after delete, after undelete) { Set<Id> accountIds = new Set<Id>(); for(Account c: Trigger.isDelete? Trigger.old : Trigger.new){ if(c.GroupName__c != null) { accountIds.add(c.GroupName__c ); } } List<CustomerGroups__c> accList = new List<CustomerGroups__c>(); for(AggregateResult currentAggResult:[SELECT GroupName__c accId, SUM(Customer_Loan_Amount__c ) sumAmt FROM Account WHERE GroupName__c in:accountIds GROUP BY GroupName__c ]) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = (Id)currentAggResult.get('accId'); acc.Customer_Group_OLB__c = (decimal)currentAggResult.get('sumAmt'); accList.add(acc); accountIds.remove((Id)currentAggResult.get('accId')); } for(Id currAccId : accountIds) { CustomerGroups__c acc = new CustomerGroups__c(); acc.Id = currAccId; acc.Customer_Group_OLB__c = null; accList.add(acc); } update accList; }
Kind regards,
Thijs
- Thijs Faber
- May 31, 2017
- Like
- 0
- Continue reading or reply
Apex trigger - faulty adjustment
Hi there,
For the last days I have been struggeling with Apex Triggers, I need to roll up a currency field from the (standard) 'Account' object to the custom 'CustomerGroups__c' object. I'd prefer avoiding Apex, but Sales Force does not allow me to make a parent for the Account object.
From the child 'Account', I'd like to roll up the currency field "Customer_OLB__c" and summarize those amounts in the parents object 'CustomerGroups__c' field 'Customer_Group_OLB__c'.
Adjusting one of the previously provided examples has lead me to to following code, where I get an problem in line 2: "unexpected token: ':' "
Kind regards,
Thijs
For the last days I have been struggeling with Apex Triggers, I need to roll up a currency field from the (standard) 'Account' object to the custom 'CustomerGroups__c' object. I'd prefer avoiding Apex, but Sales Force does not allow me to make a parent for the Account object.
From the child 'Account', I'd like to roll up the currency field "Customer_OLB__c" and summarize those amounts in the parents object 'CustomerGroups__c' field 'Customer_Group_OLB__c'.
Adjusting one of the previously provided examples has lead me to to following code, where I get an problem in line 2: "unexpected token: ':' "
trigger UpdateAccount on Account (after insert, after update, after delete, after undelete) { Map<Id,CustomerGroups__c> updateCustomerGroups = new Map<Id,CustomerGroups__c>; Set<Id> updateCustomerGroupsIds = new Map<Id,CustomerGroups__c>(); if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete) for (Account account:Trigger.new) updateCustomerGroupsIds.add(account.CustomerGroups__c_Name); if(Trigger.isUpdate || Trigger.isDelete) for (Account account:Trigger.old) updateCustomerGroupsIds.add(account.CustomerGroups__c_Name); updateCustomerGroupsIds.remove(null); for(Id CustomerGroupsId:updateCustomerGroupsIds) updateCustomerGroupsIds.put (CustomerGroupsId,new CustomerGroups (id=CustomerGroupsId,Accounts_Count=0); for Account account:[select id,CustomerGroups__c_Name from account where CustomerGroups__c_Name in :updateCustomerGroupsIds]) updateCustomerGroups.get (account.CustomerGroups__c_Name).Accounts_Count++; Database.update(updateCustomerGroups.values()); ) }Any help would be much appreciated!
Kind regards,
Thijs
- Thijs Faber
- May 30, 2017
- Like
- 0
- Continue reading or reply