You need to sign in to do that
Don't have an account?

Trigger To Update Field On OpportunityLineItem From OpportunityLineItemSchedule
Hi guys,
I have custom formula fields on the OpportunityLineItemSchedule object which display a month based on the month the scheduled date falls within.
I have created 12 custom fields on the OppLine object, each labeled one of the months of the year. I need a way of rolling up the Quantity of the the related schedules to the corresponding custom fields on the OppLine.
Has anyone created anything similar in the past?
I have custom formula fields on the OpportunityLineItemSchedule object which display a month based on the month the scheduled date falls within.
I have created 12 custom fields on the OppLine object, each labeled one of the months of the year. I need a way of rolling up the Quantity of the the related schedules to the corresponding custom fields on the OppLine.
Has anyone created anything similar in the past?
Please check the data type of the fields, there is a possibility the Fields named as 'January__c' and 'Feburary__c' are a string and Month__c is a decimal type.
Make both the type same for the fields
else try this:
If helps marked as solved.
Thanks
All Answers
"Illegal assignment from String to Decimal"
Here is my trigger
trigger MatchingMontsOnOppLineItem on OpportunityLineItemSchedule (after insert, after update) {
List<OpportunityLineItem> oli = new List<OpportunityLineItem>();
for (OpportunityLineItemSchedule sch : trigger.new)
{
if (sch.Month__c != null)
{
oli.add(new OpportunityLineItem(Id = sch.OpportunityLineItemId, January__c = sch.Month__c));
oli.add(new OpportunityLineItem(Id = sch.OpportunityLineItemId, February__c = sch.Month__c));
}
else
{
oli.add(new OpportunityLineItem(Id = sch.OpportunityLineItemId, January__c = null));
oli.add(new OpportunityLineItem(Id = sch.OpportunityLineItemId, February__c = null));
}
}
if (oli.size() > 0)
{
update oli;
}
}
Please check the data type of the fields, there is a possibility the Fields named as 'January__c' and 'Feburary__c' are a string and Month__c is a decimal type.
Make both the type same for the fields
else try this:
If helps marked as solved.
Thanks