• Prem Kumar Gupta 9
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hello Team,

My question is can we update or delete a contenttype in CMS Workspace. Using the link below, I am able to insert new content type, but while updating or deleting same name, it throw error

All Component Failures:
1.  managedContentTypes/blog.managedContentType -- Error: duplicate value found: <unknown> duplicates value on record with id: <unknown>


https://developer.salesforce.com/docs/atlas.en-us.222.0.communities_dev.meta/communities_dev/cms_dev_customcontenttypes.htm

Hi all,
I want to update CustomAmmount(Custom field) on parent(Opportunity) when child(OpportunityLineItem) updated
but its not working in after delete event
Trigger:
trigger UpdateCustomAmmount on OpportunityLineItem (after insert, after update, after Undelete,after delete) {
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUnDelete))
    {
    UpdateCustomAmmount_Handler.updateAmmount(Trigger.new);
    }
    
   /if(Trigger.isAfter ||Trigger.isDelete)
    {
      UpdateCustomAmmount_Handler.updateAmmount(Trigger.old);  
    }
}

Contoller:
public class UpdateCustomAmmount_Handler {
    public static void updateAmmount(List<OpportunityLineItem> olt)
    {
       
        List<Id> listIds = new List<Id>();
        system.debug('list of opp ids---'+listIds);
        
        for (OpportunityLineItem childItem : olt) {
            listIds.add(childItem.OpportunityId);
        }
        
          list<Opportunity> parentOpp = new List<Opportunity>([SELECT id, Custom_Ammount__c, Name,(SELECT ID, TotalPrice FROM OpportunityLineItems) FROM Opportunity WHERE ID IN :listIds]);
          system.debug('list of opp with child---'+parentOpp); 
          
        for(Opportunity opp:parentOpp)
               {
                   opp.Custom_Ammount__c = 0;
            for(OpportunityLineItem item:opp.OpportunityLineItems)
            {
               
                opp.Custom_Ammount__c += item.TotalPrice; 
               }
            }
        If(parentOpp.size()>0){
            update parentOpp;  
        }    
    }
}