• Adheesh Gupta
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hi there,

I have a trigger on OpportunityLineItem and I need to compare formula field old and new values. That formula field gets value from another related object which is CPQ Quote Line and I need that trigger to fire on OpportunityLineItem when value changes on Quote Line.
When value changes on Quote Line and fires the trigger on OpportunityLineItem I get the same new value on Trigger.new and Trigger.old list
Anyone knows how to get old variable?
 
trigger OpportunityLineItemTrigger on OpportunityLineItem (after insert, before update, after update)
{
    
    if (Trigger.isBefore && Trigger.isUpdate)
    {
        System.debug('BEFORE');
        for (OpportunityLineItem oli : Trigger.new)
        {
            System.debug(oli.Quantity_Formula__c);
        }
        for (OpportunityLineItem oli : Trigger.old)
        {
            System.debug(oli.Quantity_Formula__c);
        }
    }
    
    if (Trigger.isAfter && Trigger.isUpdate)
    {
        System.debug('AFTER');
        for (OpportunityLineItem oli : Trigger.new)
        {
            System.debug(oli.Quantity_Formula__c);
        }
        for (OpportunityLineItem oli : Trigger.old)
        {
            System.debug(oli.Quantity_Formula__c);
        }
    }
}

 

Hi all - 
I am hoping you can help me modify a trigger - currently, it fires every time a record is updated, but we need to modify it to fire upon create only - thank you!! 
1trigger AssetTrigger on Asset (before insert, before update, before delete, after insert, after update, after delete) {
2        if(Trigger.isBefore) {
3            if(Trigger.isInsert && AssetTriggerHelper.firstRunBefore) {
4                AssetTriggerHelper.setAccountOnAsset(trigger.new);
5            }
6            if(Trigger.isUpdate) {
7                AssetTriggerHelper.setAccountOnAsset(trigger.new);
8            }
9            if(Trigger.isDelete) {
10                //do nothing for now
11            }
12            AssetTriggerHelper.firstRunBefore = false;
13        }
14        
15        if(Trigger.isAfter && AssetTriggerHelper.firstRunAfter) {
16            if(Trigger.isInsert) {
17                //do nothing for now
18            }
19            if(Trigger.isUpdate) {
20                //do nothing for now
21            }
22            if(Trigger.isDelete) {
23                //do nothing for now
24            }
25            AssetTriggerHelper.firstRunAfter = false;
26        }
27    }

Hi,

I was wondering if it was possible to hide/remove the delete option in cases, if not is it possible to just create an error not auth popup?

User-added image
Testing the merge case optoin and it needs the delete enabled, managed to hide from in layout but not here.

Note: I am very new to this so as easy as possible please :)

Thanks,

Danny
Hi there,

I have a trigger on OpportunityLineItem and I need to compare formula field old and new values. That formula field gets value from another related object which is CPQ Quote Line and I need that trigger to fire on OpportunityLineItem when value changes on Quote Line.
When value changes on Quote Line and fires the trigger on OpportunityLineItem I get the same new value on Trigger.new and Trigger.old list
Anyone knows how to get old variable?
 
trigger OpportunityLineItemTrigger on OpportunityLineItem (after insert, before update, after update)
{
    
    if (Trigger.isBefore && Trigger.isUpdate)
    {
        System.debug('BEFORE');
        for (OpportunityLineItem oli : Trigger.new)
        {
            System.debug(oli.Quantity_Formula__c);
        }
        for (OpportunityLineItem oli : Trigger.old)
        {
            System.debug(oli.Quantity_Formula__c);
        }
    }
    
    if (Trigger.isAfter && Trigger.isUpdate)
    {
        System.debug('AFTER');
        for (OpportunityLineItem oli : Trigger.new)
        {
            System.debug(oli.Quantity_Formula__c);
        }
        for (OpportunityLineItem oli : Trigger.old)
        {
            System.debug(oli.Quantity_Formula__c);
        }
    }
}

 
Hi,

As I have two maps 
Map 1---Program code and ContactId
Map 2---Program Code and Program term.


Now how to get the count of uniques program code from these two map.

Any idea.
I have inherited a lot of old code which uses @future methods for doing DML operations. Is there any benefit to doing this? The only thing I can think of is in case there are a lot of records to be updated but I thought @future methods were only really used for callouts.
 
Hi,

I was wondering if it was possible to hide/remove the delete option in cases, if not is it possible to just create an error not auth popup?

User-added image
Testing the merge case optoin and it needs the delete enabled, managed to hide from in layout but not here.

Note: I am very new to this so as easy as possible please :)

Thanks,

Danny
I have inherited a lot of old code which uses @future methods for doing DML operations. Is there any benefit to doing this? The only thing I can think of is in case there are a lot of records to be updated but I thought @future methods were only really used for callouts.