• SAGAR BAWANE
  • NEWBIE
  • -6 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    Replies
Hi,
I've inherited a Sales Cloud org, that until recently had the following trigger working. Now the Original Total Cost is no longer populated at the trigger points.
However the Error at deletion is still being sucessfuly fired.
 
trigger OLITrigger on OpportunityLineItem (before insert, before update, before delete) {
    
 //Code block to enable bypassing of triggers using field off users record  
    String currentUserId = UserInfo.getUserId();
    User currentUser = [SELECT Bypass_Triggers__c FROM User WHERE Id = :currentUserId LIMIT 1];
    if (currentUser.Bypass_Triggers__c) return;
        
    If(System.Trigger.isInsert){
    
      For(OpportunityLineItem oli: Trigger.New){
    
        oli.Original_Total_Cost__c = oli.TotalPrice;
        
      }
  }
    
  If(System.Trigger.isUpdate){

       For(OpportunityLineItem oli : [SELECT TotalPrice,Original_Total_Cost__c,Opportunity.StageName FROM OpportunityLineItem Where Id IN: Trigger.New]){
           
      if(oli.Opportunity.StageName == 'Closed Won')
     {
         //Do Nothing
     }
           
      else  if(Trigger.oldmap.get(oli.id).TotalPrice == Trigger.newmap.get(oli.id).TotalPrice)
           {
               // Do nothing  
            }
                  
     else if(Trigger.oldmap.get(oli.id).TotalPrice != Trigger.newmap.get(oli.id).TotalPrice)
     {
          oli.Original_Total_Cost__c = Trigger.oldmap.get(oli.id).TotalPrice;
     }
       }
  }
       
  If(System.Trigger.isBefore &&System.Trigger.isDelete){
    
  For(OpportunityLineItem oli : Trigger.old)
    {
        if(oli.number_of_invoice_lines__c == 0 || oli.number_of_invoice_lines__c == null){

        list<Line_Item_Details__c> LineItemDetailsId=[Select Id FROM Line_Item_Details__c Where id =:oli.Line_Item_Details__c];     
        delete LineItemDetailsId;
        }
        
        else if(oli.number_of_invoice_lines__c >= 1) 
        {
            oli.addError('You can not delete this Product as it has Invoiced Schedules');
        }
       
    }
    }

}

 
My requirement is to display Account and its related contacts using accordion and accordion section.

I am able to display account and when I expand account it will show Rating and Phone but Under each account I want a separate accordion to show contact firstname and contact lastname.

Here's my code
public with sharing class MyController {

    @AuraEnabled
    public static List<Account> showAccountsForAccordion()
    {
        List<Account> accList = [select Id,Name,Rating,Phone,(select firstname,lastname from contacts)
                                 FROM 
                                 Account
                                 Order By name LIMIT 4];
        return accList;
    }
}

<aura:component implements="flexipage:availableForAllPageTypes" 
                controller="MyController"
                access="global" >
	
    <aura:attribute name="accnList"
                    type="List"/>
    
    <aura:handler name="init"
                  value="{!this}"
                  action="{!c.doInit}"/>
    
    <div class="demo-only slds-grid" style="height: 150px; width: 300px; padding: 2rem;">
    <div class="slds-is-fixed">
    <div style="position: absolute; top: 1rem; left: 1rem; border: 1px solid red; background: rgb(244, 246, 249);">
    
    <lightning:accordion>
          <aura:iteration items="{!v.accnList}" 
                          var="acc">
              
              <lightning:accordionSection name="{!acc.Name}" 
                                          label="{!acc.Name}">
                  
                   <aura:set attribute="body">
                       
                        <p>Rating : {!acc.Rating}</p>
                        <p>Phone : {!acc.Phone}</p>
                      
                    </aura:set>
                  
                  </lightning:accordionSection>
              
              <aura:iteration items="{!v.accnList.contacts}" 
                                  var="con">
                  <lightning:accordionSection name="{!con.Name}" 
                                              label="{!con.Name}">
                  
                   <aura:set attribute="body">
                       
                        <p>FirstName : {!con.FirstName}</p>
                        <p>LastNamePhone : {!con.LastName}</p>
                      
                    </aura:set>
                   </lightning:accordionSection>
                       </aura:iteration>
      </aura:iteration>
      </lightning:accordion>
  </div>
</div>
         </div>
</aura:component>


({
	doInit : function(component, event, helper) {
		
        debugger;
        var action=component.get('c.showAccountsForAccordion');
        
        action.setCallback(this,function(response){
            
            debugger;
            var state = response.getState();
            console.log('state ='+state);
            if (component.isValid() && state === "SUCCESS") {
               
                component.set("v.accnList", response.getReturnValue());
                console.log('v.accnList='+response.getReturnValue());
              }
        });$A.enqueueAction(action);
        
	}
})

Please tell me how to achieve this.

thanks
sheila
Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []
Error is in expression '{!genDoc2}' in component <apex:commandButton> in page doccontrolgather: Class.DocControlQuery.SavePDF: line 203, column 1
Class.DocControlQuery.genDoc2: line 120, column 1


I need help with this apex code.  I am not a coder :-S



 

I am working in enterprise edition. As winter 14 changed... i am unable to see the option reset security token . In devoloper edition it is visible. So from Enterprise edition i am unable to find.

  • December 16, 2013
  • Like
  • 2

Hi,

 

Is there a guide for adding 3rd party phonegap/cardova plugins to exisiting hybrid projects created using frocedroid create or forceios commands ??

 

Thanks,

Nikhil