• Iqbal
  • NEWBIE
  • 60 Points
  • Member since 2018

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 7
    Replies
I have created a report in lightning experience it had saved in the public folder, one of my users is trying to access it facing the error "insufficient privileges", the user had access to reports and dashboards, unable to figure out the reason.
Hi, i have a problem with a trigger.
I need to reduce the count when a "Iscrizione" is deleted from a Contact. The trigger doesn't work when i remove the record. How can i solve this ?

trigger ContaIscr on Iscrizione__c (after insert ,after delete) {
    set<id> studId = new set<id>();
    for(Iscrizione__c a : trigger.new){
        studId.add(a.Contact__c);
    }
    list<Contact> lstCoustumObject = [Select id, totale_iscrizioni__c from contact where id in: studId];
    for(Iscrizione__c isc : Trigger.new){
    for(Contact con : lstCoustumObject){
        if(isc.contact__c != NULL){
            con.Totale_iscrizioni__c = con.Totale_Iscrizioni__c +1;
        }else{
            con.Totale_iscrizioni__c = con.Totale_Iscrizioni__c -1;   
        }
    }
}
    update lstCoustumObject;
}
In an Apex test I am merging three pairs of Contacts (in a for loop), but before it completes I get this error:

first error: LIMIT_EXCEEDED, System.LimitException: npsp:Too many queueable jobs added to the queue: 2: []

How can I ensure only 1 queueable job is processed at one time?
I have created a report in lightning experience it had saved in the public folder, one of my users is trying to access it facing the error "insufficient privileges", the user had access to reports and dashboards, unable to figure out the reason.
Scenario : I have written a trigger to update average of cost , amount and probability of child object product at parent object sub opportunity level (Actual Cost , Actual Amount and Actual Probability ) fields. I have written three separate methods for the same , Please help me to write inside one method.
Apex Trigger:


trigger AvgCalculateTrigger on Sub_Opportunity_Product__c (after insert, after update, after delete) {
    
    if( Trigger.isInsert || Trigger.isAfter || Trigger.isDelete ){
        if( Trigger.isAfter ){
           AvgCalculate.avgCalculate();
           AvgCalculate.avgCalculate1();
            AvgCalculate.avgCalculate2();
           
           
        }
    }
        
}





Apex Class

public class AvgCalculate {

    public static void avgCalculate (){
        Set<Id> subopptyIds = new Set<Id>();
        List<Sub_Opportunity__c> subopptyToUpdate = new List<Sub_Opportunity__c>();
      
        List< Sub_Opportunity_Product__c> sub = Trigger.isInsert || Trigger.isUpdate ? Trigger.New : Trigger.Old;
        for(Sub_Opportunity_Product__c  ct : sub ){
            subopptyIds.add( ct.Sub_Opportunity__c /*lookup field value of utilityrecord */ );
        }

        for( AggregateResult ag : [ SELECT Sub_Opportunity__c, AVG( Cost__c ) avg FROM Sub_Opportunity_Product__c
                                    GROUP BY Sub_Opportunity__c ] ){
             subopptyToUpdate.add( new Sub_Opportunity__c( 
                Id = (Id)ag.get('Sub_Opportunity__c'), 
                 Actual_Cost2__c = (Decimal)ag.get('avg') ) );                            
        }
         
      
         
         
              if(subopptyToUpdate.size() > 0 ){
            update  subopptyToUpdate;
        }
        
       
    }
    public static void avgCalculate1 (){
        Set<Id> subopptyIds1= new Set<Id>();
        List<Sub_Opportunity__c> subopptyToUpdate1 = new List<Sub_Opportunity__c>();
      
        List< Sub_Opportunity_Product__c> sub1 = Trigger.isInsert || Trigger.isUpdate ? Trigger.New : Trigger.Old;
        for(Sub_Opportunity_Product__c  ct : sub1 ){
            subopptyIds1.add( ct.Sub_Opportunity__c /*lookup field value of utilityrecord */ );
        }

        for( AggregateResult ag1 : [ SELECT Sub_Opportunity__c, AVG( Amount__c ) avg FROM Sub_Opportunity_Product__c
                                    GROUP BY Sub_Opportunity__c ] ){
             subopptyToUpdate1.add( new Sub_Opportunity__c( 
                Id = (Id)ag1.get('Sub_Opportunity__c'), 
                 Actual_Revenue2__c = (Decimal)ag1.get('avg') ) );                            
        }
         
         if(subopptyToUpdate1.size() > 0 ){
            update  subopptyToUpdate1;
        }
       
    }  
      public static void avgCalculate2 (){
        Set<Id> subopptyIds2= new Set<Id>();
        List<Sub_Opportunity__c> subopptyToUpdate2 = new List<Sub_Opportunity__c>();
      
        List< Sub_Opportunity_Product__c> sub2 = Trigger.isInsert || Trigger.isUpdate ? Trigger.New : Trigger.Old;
        for(Sub_Opportunity_Product__c  ct : sub2 ){
            subopptyIds2.add( ct.Sub_Opportunity__c /*lookup field value of utilityrecord */ );
        }

        for( AggregateResult ag2 : [ SELECT Sub_Opportunity__c, AVG( Probability__c ) avgprob FROM Sub_Opportunity_Product__c
                                    GROUP BY Sub_Opportunity__c ] ){
             subopptyToUpdate2.add( new Sub_Opportunity__c( 
                Id = (Id)ag2.get('Sub_Opportunity__c'), 
                 Probability__c = (Decimal)ag2.get('avgprob') ) );                            
        }
         
         if(subopptyToUpdate2.size() > 0 ){
            update  subopptyToUpdate2;
        }
       
    }  
  
 }
 
Hi, i have a problem with a trigger.
I need to reduce the count when a "Iscrizione" is deleted from a Contact. The trigger doesn't work when i remove the record. How can i solve this ?

trigger ContaIscr on Iscrizione__c (after insert ,after delete) {
    set<id> studId = new set<id>();
    for(Iscrizione__c a : trigger.new){
        studId.add(a.Contact__c);
    }
    list<Contact> lstCoustumObject = [Select id, totale_iscrizioni__c from contact where id in: studId];
    for(Iscrizione__c isc : Trigger.new){
    for(Contact con : lstCoustumObject){
        if(isc.contact__c != NULL){
            con.Totale_iscrizioni__c = con.Totale_Iscrizioni__c +1;
        }else{
            con.Totale_iscrizioni__c = con.Totale_Iscrizioni__c -1;   
        }
    }
}
    update lstCoustumObject;
}
on the Standard record page,
When ever i select status as closed , i need to display the three dynamic fileds in a popup or in a screen which are already created in the lead object, need to fill that dynamic fileds and then it should saving.

Note: The dynamic fileds are not displayed in the pagelayout , its just created in the lead object, and dynamic fileds should display only if the status is selected as closed in the standard record page.

Any suggestions to achieve it in standard record page functionality

Thanks 
salesforce sfdx
Can you deserializeUntyped with JSON arrays?
I'm finding it difficult to get down into the "client" level so that I can retrieve ID and Status. 
results.get('items') was easy enough at the top level, but attempting results.get('client') fails.

Using this JSON:
{
    "items": [
        {
            "client": {
                "id": "xyz65240-a8e0-4184-8aaa-8b381ea83ce5",
                "status": "enabled"
            }
        },
        {
            "client": {
                "id": "8b265241-3662-4a49-b7dd-97f948ca9bb6",
                "status": "enabled"
            }
        }
    ]
}

Using this code:
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());

List<Object> items = (List<Object>) results.get('items');
    System.debug('Received the following items:');
    for (Object item: items) {
        System.debug('Item:');
        System.debug(item);
    }
I am trying to generate some S-Doc templates for a department to use.  We want to generate letters that hold the Name, Date, and Amounts associated with transactions.  Several of our letters are similar in nature, with just a few elements being different.

I understand that I can use the Insert RENDER button to set up some conditional testing to have certain parts of the template display if the criteria are met.  However, I have 6 letters that are very similar (only differing by a paragraph at most).  I am concerned that by using the RENDER feature, it will cause the formatting of the letter to be completely messed up.

I know we can ask the user for information as part of a Runtime Prompt.  I can then use the runtime prompts on the template as part of the information. However, I'm wondering if I can use the runtime prompt to determine what template to actually use.

For example, if I select a Denial case type, and that the User Knew the Person making the transaction, I would open template A.  But if I select a Denial case type, and that the PIN on the card was used, then template B would open.  Is this possible within S-Docs?  Or do I need to create a custom component/VF page?