• Monin Savant
  • NEWBIE
  • 40 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 0
    Replies
I need to take the request out of the loop to avoid limits. Where Opportunity__c field in Depositor__c its has master-detail relationships with Opportunity.
Depositor__c[] depositors = trigger.new;
for (Depositor__c item : depositors) {
            List<AggregateResult> resultAmount = [SELECT SUM(Amount__c)sum 
                            FROM Depositor__c
                            WHERE Opportunity__c=:item.Opportunity__c];

Thanks in advance!
I want to create a class object knowing only its name. This object belongs to Batch, but I don't know which one. So i have to run it by name only. i get error when i pass sObject to executeBatch.
 
@AuraEnabled
    public static void run(String batchName){
        sObject newObject = (sObject)Type.forName(batchName).newInstance();
        Database.executeBatch(newObject);
    }
How to bypass it.
Thanks in advance.
Hello!

I want to preview pdf file from lwc component. I get the id of all files that refer to the record, but when I click on the button, I get the message
"Error in $A.getCallback() [Cannot read properties of undefined (reading 'errors')]". Why

My JS file 
 
previewHandler()
    {
        this[NavigationMixin.Navigate]({
            type: 'standard__namedPage',
            attributes: {
                pageName: 'filePreview'
            },
            state : {
                recordIds: this.files,
               selectedRecordId: this.files[0]
            }
          })

    }

Thanks in advance!
 
I am creating an attachment, but I want to check if it does not exist with the same name.
a = (Opportunity)standardPageController.getRecord();
 PageReference pdfPage = new PageReference('/apex/myPage');
        Opportunity b =[select Id, Name Invoice_Number__c from Opportunity where Id=:a.id];
        Blob pdfBlob;

Attachment attach = new Attachment(
        parentId = a.Id,
        Name = b.Name +'.pdf', 
        body = pdfBlob); //create the attachment object
        insert attach;

 
I try check if opportunity exists.
I know for sure that yes and it goes into a loop, but then it throws an error 'System.NullPointerException'. Why?
@AuraEnabled(cacheable=true)
    public static List<Account> getRecById(String recId) {
        List<Account> listofaccts = [SELECT Total_Opportunity_Amount__c, Name, (SELECT Id, Name, Amount, CreatedDate, CloseDate FROM Opportunities WHERE StageName = 'Closed Won' ) FROM Account WHERE id=:recId ];
         List<Account> resultAcc;
        for(Account acc : listofaccts){
              if(!acc.Opportunities.isEmpty())
              {
                  resultAcc.add(acc);
              }
           }
         return resultAcc;
    }
Thanks in advance.
 
I need to take the request out of the loop to avoid limits. Where Opportunity__c field in Depositor__c its has master-detail relationships with Opportunity.
Depositor__c[] depositors = trigger.new;
for (Depositor__c item : depositors) {
            List<AggregateResult> resultAmount = [SELECT SUM(Amount__c)sum 
                            FROM Depositor__c
                            WHERE Opportunity__c=:item.Opportunity__c];

Thanks in advance!