• Seksaki
  • NEWBIE
  • 35 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies
Hello,
I have a lookup relashionship between Contract (Parent) and  DeliveryPoint (child), i want to retrive the delivery point from one or every contract but the query not work:
 
SELECT Id ,(select id DeliveryPoint__r) FROM Contract

Thanks for Help
Hello,
I use API calls from tanlend studio, the problem is triggered when I insert contracts from the API, a trigger that I set up at contract level is triggered,
how can I deactivate it or not launch it when I call the API

Thanks
Hello,
can you help me write a test for this trigger plz
trigger ContractTrigger on Contract (after update) {
    Public String[] statut_activated   {set;get;}
    Public String[] statut_waiting   {set;get;}
    Public String[] statut_terminated   {set;get;}
    
    statut_activated = new String[] {'Accepted','Accepted2'};
    statut_waiting = new String[] {'waiting','waiting2'}; 
    statut_terminated = new String[] {'terminated','terminated2'}; 

    
    List<Decimal> listAmount= new List<Decimal>();
	set<Id> AccountIds = new set<Id>();
    for(Contract c : Trigger.new){
    if(c.AccountId != null)
    	AccountIds.add(c.AccountId);
    }

  

    Map<String, Contract> cntrMap  = new Map<String, Contract>();
    
    for(Contract contr : [Select Id,contract_stat__c,amount__c From Contract Where AccountId IN: AccountIds]){
        cntrMap.put(contr.Id , contr);
         
         Account acc = [SELECT Id,st__c FROM Account WHERE Id IN: AccountIds];	
        if(contr.amount__c > 0){
            listAmount.add(contr.amount__c);
        }else{
          acc.checked__c=FALSE;
          update acc;
        }
        
       
        if(statut_activated.contains(contr.contract_stat__c)){
             cntrMap.put(contr.contract_stat__c , contr);     
             acc.st__c='customer';   
             update acc;
             break;
            
            /* Contrat En attente*/ 
        }else if(statut_waiting.contains(contr.contract_stat__c)){

             acc.st__c='customer_type2';
             update acc;
             break;
        /*  Contrat En Terminé  */ 
        }else if(statut_terminated.contains(contr.contract_stat__c)){
		
             acc.st__c='customer_type3';
             update acc;
             break;     
        }else{

             acc.st__c='customer_other';
             update acc;       
        }
    }

    for(Decimal l : listAmount){
    	if(l > 0){
          Account acc = [SELECT Id,st__c FROM Account WHERE Id IN: AccountIds];	
          acc.checked__c=TRUE;
          update acc;
         }
	}

}

Thanks for help 
Hello,
When updating a contract I want to retrieve the list of contracts attached to this client and I check a field in at least one contract  and I update the account .
what is the best solution : process builder or trigger .. ?
Thanks for help.
Hello,
I have a lookup relashionship between Contract (Parent) and  DeliveryPoint (child), i want to retrive the delivery point from one or every contract but the query not work:
 
SELECT Id ,(select id DeliveryPoint__r) FROM Contract

Thanks for Help
Hello,
I use API calls from tanlend studio, the problem is triggered when I insert contracts from the API, a trigger that I set up at contract level is triggered,
how can I deactivate it or not launch it when I call the API

Thanks
Hello,
can you help me write a test for this trigger plz
trigger ContractTrigger on Contract (after update) {
    Public String[] statut_activated   {set;get;}
    Public String[] statut_waiting   {set;get;}
    Public String[] statut_terminated   {set;get;}
    
    statut_activated = new String[] {'Accepted','Accepted2'};
    statut_waiting = new String[] {'waiting','waiting2'}; 
    statut_terminated = new String[] {'terminated','terminated2'}; 

    
    List<Decimal> listAmount= new List<Decimal>();
	set<Id> AccountIds = new set<Id>();
    for(Contract c : Trigger.new){
    if(c.AccountId != null)
    	AccountIds.add(c.AccountId);
    }

  

    Map<String, Contract> cntrMap  = new Map<String, Contract>();
    
    for(Contract contr : [Select Id,contract_stat__c,amount__c From Contract Where AccountId IN: AccountIds]){
        cntrMap.put(contr.Id , contr);
         
         Account acc = [SELECT Id,st__c FROM Account WHERE Id IN: AccountIds];	
        if(contr.amount__c > 0){
            listAmount.add(contr.amount__c);
        }else{
          acc.checked__c=FALSE;
          update acc;
        }
        
       
        if(statut_activated.contains(contr.contract_stat__c)){
             cntrMap.put(contr.contract_stat__c , contr);     
             acc.st__c='customer';   
             update acc;
             break;
            
            /* Contrat En attente*/ 
        }else if(statut_waiting.contains(contr.contract_stat__c)){

             acc.st__c='customer_type2';
             update acc;
             break;
        /*  Contrat En Terminé  */ 
        }else if(statut_terminated.contains(contr.contract_stat__c)){
		
             acc.st__c='customer_type3';
             update acc;
             break;     
        }else{

             acc.st__c='customer_other';
             update acc;       
        }
    }

    for(Decimal l : listAmount){
    	if(l > 0){
          Account acc = [SELECT Id,st__c FROM Account WHERE Id IN: AccountIds];	
          acc.checked__c=TRUE;
          update acc;
         }
	}

}

Thanks for help 
Hello,
When updating a contract I want to retrieve the list of contracts attached to this client and I check a field in at least one contract  and I update the account .
what is the best solution : process builder or trigger .. ?
Thanks for help.