• ZANE PRATER
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 17
    Replies
This is so on the vf page a user has to select a value (custom field on ContentVersion) object that will append to the file name they upload from the windows explorer.  The files will then need to be displayed in the Files related list.
We recently scanned all Apex for our org and found multiple security findings with message: URL parameters should be escaped/sanitized XSS. May be tainted: when using variable pageid.  Does anyone know what this means?  Here is a snippit of code where it is referencing 'pageid' in the page reference var.

id pageid=ApexPages.currentPage().getParameters().get('id');
PageReference ref =  new PageReference('/'+pageid);
 
Here is the code and trigger works fine with a single update but fails the whole batch when one fails.
 
trigger AgreementTrigger on Apttus__APTS_Agreement__c (after update, before update) {
    
    set<Id> agmts = new set<Id>();
    set<Id> agmts2 = new set<Id>();
    set<Id> pbuns = new set<Id>();
    
    List<Product_Bundle__c > pbs = [Select Id From Product_Bundle__c Where Bundle_Type__c = 'Service Pack'];
    
    For(Product_Bundle__c pb : pbs)
        
        If(pbs.size() > 0) {
            
            pbuns.add(pb.Id);
            
            system.debug('^^^^^^^^^^^^^^'+pbuns);
            
        }
    List<Apttus__AgreementLineItem__c> lines = new list<Apttus__AgreementLineItem__c>();
    List<Apttus__AgreementLineItem__c> lines2 = new list<Apttus__AgreementLineItem__c>();
    List<Apttus__AgreementLineItem__c> lines3 = new list<Apttus__AgreementLineItem__c>();        
    
    if(trigger.isUpdate){
        if(trigger.isAfter){
            AgreementTriggerClass.onAfterUpdate(trigger.newMap);
        }
        else if(trigger.isBefore){
            for(Apttus__APTS_Agreement__c aptusap : trigger.New){
                if(aptusap.Auto_Renewal_cust__c == 'Yes')
                    aptusap.Apttus__Auto_Renewal__c = True;
                if(aptusap.Auto_Renewal_cust__c == 'No')
                    aptusap.Apttus__Auto_Renewal__c = False;
                
                if(aptusap.Apttus__Status__c == 'Ready for Signatures' || aptusap.Apttus__Status__c == 'Activated') {
                    
                    agmts.add(aptusap.Id);  
                    
                    system.debug('###############'+agmts);
                    
                } 
                
                if(aptusap.Apttus__Status__c == 'Activated') {
                    
                    agmts2.add(aptusap.Id); 
                } 
            }
            lines = [Select Id From Apttus__AgreementLineItem__c Where Apttus__AgreementId__c In: agmts AND Product_Bundle__r.Product_Bundle__c
                     In: pbuns]; 
            
            If(lines.size()>0) {
                
                lines2 =[Select Id From Apttus__AgreementLineItem__c Where Apttus__AgreementId__c In: agmts];
                
            }
            
            lines3=[Select Id, POB__c, GL_String__c From Apttus__AgreementLineItem__c Where
                    Apttus__AgreementId__c In:agmts2 AND Apttus__AgreementId__r.Rev_Customer__c = true];
            
        }
        
        system.debug('$$$$$$$$$$$$$$'+lines);
        
        For(Apttus__APTS_Agreement__c apt: trigger.new) {  
            For(Apttus__AgreementLineItem__c lis:lines2) {
                If(lines2.size()<2) {
                    
                    system.debug('***********'+lines.size());
                    
                    apt.addError('Agreement needs to have more than one agreement line when there is a service pack.'); 
                }
                
                
                
            }
        }
        //logic for SFCON-880
        list<Apttus__APTS_Agreement__c> lstNewAgt = Trigger.new;
        list<Apttus__APTS_Agreement__c> lstOldAgt = Trigger.old;
        Map<Id, Apttus__APTS_Agreement__c> mapOld = new Map<Id, Apttus__APTS_Agreement__c>();
        Set<Id> agtid = new Set<Id>();
        For(Apttus__APTS_Agreement__c old:trigger.old) {
            
            mapOld.put(old.Id, old);
        }
        
        For(Apttus__APTS_Agreement__c apt: trigger.new) {
            //mapNew.put(apt.Id, apt);
            For(Apttus__AgreementLineItem__c lis:lines3) {
                If((lines3.size()>0) && (lis.POB__c==NULL)) {
                    If(apt.Apttus__Status__c != mapOld.get(apt.Id).Apttus__Status__c) {
                        system.debug('@@@@@@OLD MAP ' +mapOld.get(apt.Id).Apttus__Status__c);
                        system.debug('@@@@@@NEW MAP ' +apt.Apttus__Status__c);
                        agtid.add(apt.id);
                        apt.addError('Every Agreement Line Item should have a POB populated.');
                        
                        system.debug('%%%%%%%%%%%%'+lines3);
                    }
                }
            }
        }
        //store the result for each record
        List<Apttus__APTS_Agreement__c> ag2 = [Select Id From Apttus__APTS_Agreement__c Where Id In: agtid];
        Database.SaveResult[] srList = Database.update(ag2, false);
        
        // Iterate through each returned result and all allow partial processing of records on failure
        for (Database.SaveResult sr : srList) {
            if (sr.isSuccess()) {
                // Operation was successful, so get the ID of the record that was processed
                System.debug('Successfully inserted account. Agreement ID: ' + sr.getId());
            }
            else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('The following error has occurred.');                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Agreement fields that affected this error: ' + err.getFields());
                }
            }
        }
    }
}

 
I have a batch job that looks at when a contract end date is greater than today, that it then creates a new record for renewal.  I am trying to dynamically set the name of the record of the original contract and append each time/counter it has been renewed.  For example, contract A is past the end date, contract B is created and Contract B name is 'contract A name' + renewed 01.  Then if contract B is past the end date, contract C is created and Contract C name is 'contract B name' + renewed 02.  Etc...
Hello, I am needing to create a custom sequence number specific to its parent. Requirement:
There can be duplicate sequence numbers as its only relating to the associated parent meaning both parent A and parent B can have 1,2,3,..  My trigger is based only on insert of a new record so if no records have been created for parent A then sequence number is 1.  If parent B has 1 then new record will have sequence number 2 and so forth. 
Error when compiling:
Arithmetic expressions must use numeric arguments at line 23 column 27
Code:
trigger PricingConfigItemSequence on Tiered_Pricing_Configuration_Item__c (before insert) {
    
    set<id> pricingconfigids = new set<id>();
    
    if(CheckRecursive.run=true){ //check recursion
    checkrecursive.run=false;
    
    for(Tiered_Pricing_Configuration_Item__c tc:trigger.new) {
    
    pricingconfigids.add(tc.Tiered_Pricing_Configuration__c);
    
    system.debug('%%%%%%%%%%%%%%%%%' + pricingconfigids);
    
    }
    
    AggregateResult[] MaxResults = [Select MAX(Tier_Sequence__c)maxi FROM Tiered_Pricing_Configuration_Item__c Where
    Tiered_Pricing_Configuration__c IN: pricingconfigids];
    For(AggregateResult ar: MaxResults) {

    Object MaxNum = MaxResults[0].get('maxi');

    ar.Tier_Sequence__c = MaxNum +1; 
    }
  }     
   checkrecursive.run = true;
}
Here is the code and trigger works fine with a single update but fails the whole batch when one fails.
 
trigger AgreementTrigger on Apttus__APTS_Agreement__c (after update, before update) {
    
    set<Id> agmts = new set<Id>();
    set<Id> agmts2 = new set<Id>();
    set<Id> pbuns = new set<Id>();
    
    List<Product_Bundle__c > pbs = [Select Id From Product_Bundle__c Where Bundle_Type__c = 'Service Pack'];
    
    For(Product_Bundle__c pb : pbs)
        
        If(pbs.size() > 0) {
            
            pbuns.add(pb.Id);
            
            system.debug('^^^^^^^^^^^^^^'+pbuns);
            
        }
    List<Apttus__AgreementLineItem__c> lines = new list<Apttus__AgreementLineItem__c>();
    List<Apttus__AgreementLineItem__c> lines2 = new list<Apttus__AgreementLineItem__c>();
    List<Apttus__AgreementLineItem__c> lines3 = new list<Apttus__AgreementLineItem__c>();        
    
    if(trigger.isUpdate){
        if(trigger.isAfter){
            AgreementTriggerClass.onAfterUpdate(trigger.newMap);
        }
        else if(trigger.isBefore){
            for(Apttus__APTS_Agreement__c aptusap : trigger.New){
                if(aptusap.Auto_Renewal_cust__c == 'Yes')
                    aptusap.Apttus__Auto_Renewal__c = True;
                if(aptusap.Auto_Renewal_cust__c == 'No')
                    aptusap.Apttus__Auto_Renewal__c = False;
                
                if(aptusap.Apttus__Status__c == 'Ready for Signatures' || aptusap.Apttus__Status__c == 'Activated') {
                    
                    agmts.add(aptusap.Id);  
                    
                    system.debug('###############'+agmts);
                    
                } 
                
                if(aptusap.Apttus__Status__c == 'Activated') {
                    
                    agmts2.add(aptusap.Id); 
                } 
            }
            lines = [Select Id From Apttus__AgreementLineItem__c Where Apttus__AgreementId__c In: agmts AND Product_Bundle__r.Product_Bundle__c
                     In: pbuns]; 
            
            If(lines.size()>0) {
                
                lines2 =[Select Id From Apttus__AgreementLineItem__c Where Apttus__AgreementId__c In: agmts];
                
            }
            
            lines3=[Select Id, POB__c, GL_String__c From Apttus__AgreementLineItem__c Where
                    Apttus__AgreementId__c In:agmts2 AND Apttus__AgreementId__r.Rev_Customer__c = true];
            
        }
        
        system.debug('$$$$$$$$$$$$$$'+lines);
        
        For(Apttus__APTS_Agreement__c apt: trigger.new) {  
            For(Apttus__AgreementLineItem__c lis:lines2) {
                If(lines2.size()<2) {
                    
                    system.debug('***********'+lines.size());
                    
                    apt.addError('Agreement needs to have more than one agreement line when there is a service pack.'); 
                }
                
                
                
            }
        }
        //logic for SFCON-880
        list<Apttus__APTS_Agreement__c> lstNewAgt = Trigger.new;
        list<Apttus__APTS_Agreement__c> lstOldAgt = Trigger.old;
        Map<Id, Apttus__APTS_Agreement__c> mapOld = new Map<Id, Apttus__APTS_Agreement__c>();
        Set<Id> agtid = new Set<Id>();
        For(Apttus__APTS_Agreement__c old:trigger.old) {
            
            mapOld.put(old.Id, old);
        }
        
        For(Apttus__APTS_Agreement__c apt: trigger.new) {
            //mapNew.put(apt.Id, apt);
            For(Apttus__AgreementLineItem__c lis:lines3) {
                If((lines3.size()>0) && (lis.POB__c==NULL)) {
                    If(apt.Apttus__Status__c != mapOld.get(apt.Id).Apttus__Status__c) {
                        system.debug('@@@@@@OLD MAP ' +mapOld.get(apt.Id).Apttus__Status__c);
                        system.debug('@@@@@@NEW MAP ' +apt.Apttus__Status__c);
                        agtid.add(apt.id);
                        apt.addError('Every Agreement Line Item should have a POB populated.');
                        
                        system.debug('%%%%%%%%%%%%'+lines3);
                    }
                }
            }
        }
        //store the result for each record
        List<Apttus__APTS_Agreement__c> ag2 = [Select Id From Apttus__APTS_Agreement__c Where Id In: agtid];
        Database.SaveResult[] srList = Database.update(ag2, false);
        
        // Iterate through each returned result and all allow partial processing of records on failure
        for (Database.SaveResult sr : srList) {
            if (sr.isSuccess()) {
                // Operation was successful, so get the ID of the record that was processed
                System.debug('Successfully inserted account. Agreement ID: ' + sr.getId());
            }
            else {
                // Operation failed, so get all errors                
                for(Database.Error err : sr.getErrors()) {
                    System.debug('The following error has occurred.');                    
                    System.debug(err.getStatusCode() + ': ' + err.getMessage());
                    System.debug('Agreement fields that affected this error: ' + err.getFields());
                }
            }
        }
    }
}

 
I have a batch job that looks at when a contract end date is greater than today, that it then creates a new record for renewal.  I am trying to dynamically set the name of the record of the original contract and append each time/counter it has been renewed.  For example, contract A is past the end date, contract B is created and Contract B name is 'contract A name' + renewed 01.  Then if contract B is past the end date, contract C is created and Contract C name is 'contract B name' + renewed 02.  Etc...
Hello, I am needing to create a custom sequence number specific to its parent. Requirement:
There can be duplicate sequence numbers as its only relating to the associated parent meaning both parent A and parent B can have 1,2,3,..  My trigger is based only on insert of a new record so if no records have been created for parent A then sequence number is 1.  If parent B has 1 then new record will have sequence number 2 and so forth. 
Error when compiling:
Arithmetic expressions must use numeric arguments at line 23 column 27
Code:
trigger PricingConfigItemSequence on Tiered_Pricing_Configuration_Item__c (before insert) {
    
    set<id> pricingconfigids = new set<id>();
    
    if(CheckRecursive.run=true){ //check recursion
    checkrecursive.run=false;
    
    for(Tiered_Pricing_Configuration_Item__c tc:trigger.new) {
    
    pricingconfigids.add(tc.Tiered_Pricing_Configuration__c);
    
    system.debug('%%%%%%%%%%%%%%%%%' + pricingconfigids);
    
    }
    
    AggregateResult[] MaxResults = [Select MAX(Tier_Sequence__c)maxi FROM Tiered_Pricing_Configuration_Item__c Where
    Tiered_Pricing_Configuration__c IN: pricingconfigids];
    For(AggregateResult ar: MaxResults) {

    Object MaxNum = MaxResults[0].get('maxi');

    ar.Tier_Sequence__c = MaxNum +1; 
    }
  }     
   checkrecursive.run = true;
}