• CharuDutt
  • ALL STAR
  • 9621 Points
  • Member since 2020
  • ACS


  • Chatter
    Feed
  • 307
    Best Answers
  • 0
    Likes Received
  • 8
    Likes Given
  • 3
    Questions
  • 1239
    Replies

I have a multiple case flow.
Flow works when activated, however, when I do a debug on all case object flow I am getting this debug log error.
CANNOT_EXECUTE_FLOW_TRIGGER : We can't save this record because the “Case: Create and/or Update Contact Email to Case” process failed
 
The flow Case: Create and/or Update Contact Email to Case has already been deleted
 
NOTE, I do not have a related contact record update node in this flow (NOT Case: Create and/or Update Contact Email to Case) 
Even on a new flow I am getting the same error message on debug.
Note : I do not have a field on case object named "[Last Name]"

 

User-added image

1- Write a batch class to update leads status as closed lost if no activity has been performed for last 30 days and send notification to manager
I am getting the attached wrrorUser-added image
global class UpdateLeadStatusBatch implements Database.Batchable<sObject> {

    global Database.QueryLocator start(Database.BatchableContext BC) {
        DateTime thirtyDaysAgo = System.now().addDays(-30);
        String query = 'SELECT Id, OwnerId, Owner.ManagerId__c FROM Lead WHERE LastActivityDate <= :thirtyDaysAgo AND Status != \'Closed - Lost\'';
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<sObject> scope) {
        List<Lead> leadsToUpdate = new List<Lead>();
        Set<Id> managerIds = new Set<Id>();

        for (sObject s : scope) {
            Lead lead = (Lead) s;
            lead.Status = 'Closed - Lost';
            leadsToUpdate.add(lead);

            // Access the manager's Id through the custom field
            Id managerId = (Id)lead.get('Owner.ManagerId__c');
            if (managerId != null) {
                managerIds.add(managerId);
            }
        }

        update leadsToUpdate;

        // Send Notification to Managers
        // Using Email Services to send email notifications
        if (!managerIds.isEmpty()) {
            List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();

            for (Id managerId : managerIds) {
                // Construct and send email to the manager
                User managerUser = [SELECT Id, Email FROM User WHERE Id = :managerId LIMIT 1];

                if (managerUser != null && !String.isBlank(managerUser.Email)) {
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setSubject('Lead Status Update');
                    email.setHtmlBody('<p>Hello, ' + managerUser.Name + ',</p>' +
                                      '<p>The status of some leads has been updated to "Closed - Lost" due to inactivity.</p>' +
                                      '<p>Thank you!</p>');
                    email.setTargetObjectId(managerUser.Id);
                    email.setSaveAsActivity(false);
                    emailMessages.add(email);
                }
            }

            if (!emailMessages.isEmpty()) {
                List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailMessages);
                for (Messaging.SendEmailResult result : sendResults) {
                    if (!result.isSuccess()) {
                        System.debug('Failed to send email: ' + result.getErrors()[0].getMessage());
                    }
                }
            }
        }
    }

    global void finish(Database.BatchableContext BC) {
        // Any logic you want to execute after the batch finishes
    }
}
 
Develop a trigger that sends an email notification to the account owner when a high-priority case is created or updated.

I have written the below code but email is not getting fired 

public class CaseEmailNotificationHandler {
    public static void sendEmailNotifications(List<Case> casesToUpdate) {
        List<Messaging.SingleEmailMessage> emailMessages = new List<Messaging.SingleEmailMessage>();
 
        // Collect Account Owner Ids for high-priority cases and fetch User information
        Map<Id, User> accountOwners = new Map<Id, User>();
        
        for (Case updatedCase : casesToUpdate) {
            if (updatedCase.Priority == 'High') {
                Id ownerId = updatedCase.Account.OwnerId;
                
                // Check if the ownerId has not been processed already
                if (!accountOwners.containsKey(ownerId)) {
                    List<User> owners = [SELECT Id, Name, Email FROM User WHERE Id = :ownerId LIMIT 1];
                    if (!owners.isEmpty()) {
                        accountOwners.put(ownerId, owners[0]);
                    } else {
                        System.debug('No User found for ownerId: ' + ownerId);
                    }
                }
 
                User accountOwner = accountOwners.get(ownerId);

                if (accountOwner != null && !String.isBlank(accountOwner.Email)) {
                    // Create email message
                    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                    email.setSubject('High-Priority Case Notification');
                    email.setHtmlBody('<p>Hello, ' + accountOwner.Name + ',</p>' +
                                      '<p>A high-priority case has been created or updated. Please review the details.</p>' +
                                      '<p>Case Number: ' + updatedCase.CaseNumber + '</p>' +
                                      '<p>Case Subject: ' + updatedCase.Subject + '</p>' +
                                      '<p>Priority: ' + updatedCase.Priority + '</p>' +
                                      '<p>Thank you!</p>');
                    email.setTargetObjectId(accountOwner.Id);
                    email.setSaveAsActivity(false);
                    emailMessages.add(email);
                } else {
                    System.debug('Email not sent due to missing or invalid recipient for case Id: ' + updatedCase.Id);
                }
            }
        }
         
        if (!emailMessages.isEmpty()) {
            List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailMessages);
            for (Messaging.SendEmailResult result : sendResults) {
                if (!result.isSuccess()) {
                    System.debug('Failed to send email: ' + result.getErrors()[0].getMessage());
                }
            }
        }
    }
}
trigger CaseEmailNotificationTrigger on Case (after insert, after update) {
    if (Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)) {
        CaseEmailNotificationHandler.sendEmailNotifications(Trigger.new);
    }
}
Hello everyone, Just wanted to ask why my SOQL query is not working inside @RestResource?
 
List<Account> recordToUpdate = [Select id from Account where id = '001Dn00000PideYIAR' LIMIT 1];
System.debug(!recordToUpdate.isEmpty());

This code inside @RestResource returns false, which means that it can't get any record. 
But if I run the same code inside the Developer Console it returns true. Why is that?User-added image 
Also using Query Editor shows a record
User-added image

Any help would be appreciated. Thanks in advance!

Regards,
Ryan

 

OR (
$RecordType.Name = "Release",$RecordType.Name ='Digital Part Release'),
ISPICKVAL(Card_Closure_Status__c, 'None'),
IF( Associated_Credit_Card__c = 'Yes',True,False),
)
HTML >>>
<template>
   
    <div class="slds-m-top_medium slds-m-bottom_x-large">
        <h2 class="slds-text-heading_medium slds-m-bottom_medium">
            Button-icons with the <code>variant</code> attribute omitted or set to the default value of <code>border</code>.
        </h2>
        <!-- with border / by default -->
        <div class="slds-p-around_medium lgc-bg">
            <lightning-button-icon icon-name="utility:add"  alternative-text="New Request" title="New request" onclick={showModalpopUp}></lightning-button-icon>
            <template if:true={isModalpopupTrue}>
                <!-- //<c-modal-popup-component></c-modal-popup-component> -->
                <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                    <div class="slds-modal__container">
                     <!-- modal header start -->
                       <header class="slds-modal__header">
                          <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
                             <lightning-icon icon-name="utility:close"
                                alternative-text="close"
                                variant="inverse"
                                size="small" ></lightning-icon>
                             <span class="slds-assistive-text">Close</span>
                          </button>
                          <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Leave Request</h2>
                       </header>
                   
                       <!-- modal body start -->
                       <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <lightning-record-edit-form object-api-name={objectApiName}
                        record-id={recordId} onsuccess={handleSuccess}>
                        <lightning-messages></lightning-messages>
                        <lightning-input-field field-name={user}> </lightning-input-field>
                        <lightning-input-field field-name={FromDate}> </lightning-input-field>
                        <lightning-input-field field-name={Todate}> </lightning-input-field>
                        <lightning-input-field field-name={Reason}> </lightning-input-field>
                        <lightning-button  variant="brand"  type="submit" name="save" label="Save">
                        </lightning-button>
                        <lightning-button   type="submit" name="Cancel" label="Cancel" onclick={hideModalBox}>
                        </lightning-button>
                        </lightning-record-edit-form>
                             
                       </div>
             
                       <!-- modal footer start
                       <footer class="slds-modal__footer">
                        <lightning-button  variant="brand"  type="submit" name="save" label="Save">
                        </lightning-button>
                          <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button>
                       </footer> -->
                   
                    </div>
                 </section>
                 <div class="slds-backdrop slds-backdrop_open"></div>
           
            </template>
        </div>
        <div style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={tabledata}
                    columns={columns}
                    hide-checkbox-column
                    onrowaction={handleRowAction}>
            </lightning-datatable>
        </div>
    </div>        
</template>

Js file >>>>>>>>> 

 showModalpopUp(){
       this.isModalpopupTrue = true;
       console.log('Get the details of Lig input tag >>>>>>'+this.template.querySelectorAll("lightning-input-field"));
       
       this.template.querySelectorAll('lightning-input').forEach(element => {            
        element.value = null;
      });  
    }

Getting error as  >>
Get the details of Lig input tag >>>>>>SecureNodeList: [object NodeList]{ key: {"namespace":"c"} }
How to trigger the bell notification when a file is attached to a task record. We only want the bell notification to trigger when the task is owned by specific role. Thanks
Here is my code, 
//1/to get parent unique id
Set<Id> accountIDs=new Set<Id>();
            for(Opportunity oppRecord:Trigger.new)
            {
                if(oppRecord.AccountId!=null)
                    accountIDs.add(oppRecord.AccountId);
            }
//2. parent to child relationship 
            List<Account> accountList=[Select ID, Rating, Highest_opp_record__c,
                                       (Select ID, StageName, Amount,AccountID FROM Opportunities Where Amount>=50000)
                                       FROM Account Where ID in:accountIDs
                                       ];
//3. update the amount in account record
            List<Account> accList=new List<Account>();                      
            for(Account accRecord:accountList)
            {
                accRecord.Highest_opp_record__c=(accRecord.Opportunities).Amount;
                accList.add(accRecord);
                
            }
            if(accList.size()>0)
                update acclist;
        }
While creating a record in opportunity am facing the below error:
System.QueryException: List has more than 1 row for assignment to SObject Trigger.OpportunityTriggerAmount: line 27, column 1
 
I want to create one picklist namely rating and having values 1,2,3,4,5 and we have five images of 1 star , 2 star etc upto 5 star and wanted to create one image formula field where we will be able able to see images which we have from 1 star to 5 star.
How to acieve this?

Thanks
Exporting Report From Salesforce In Excel And CSV Formatl Report Event Is Not Tracking Format Type For Excel It Only Tracks For Csv

SELECT Id, User.name, EventDate, ExportFileFormat, Format, ReportId, IsScheduled, Name FROM ReportEvent
Hi All

I have used one utility icon for the icon-name attribute of lightning-card.

<lightning-card title="Account GMV" icon-name="utility:table"></lightning-card>

By default the utility icon will be displayed with no colour. Now I want to give a colour to it.

I tried add a CSS class inside the tag and write css code to give colur. That didn't work.
<lightning-card title="Account GMV" class ="greenClour" icon-name="utility:table"></lightning-card>

.THIS.greenClour svg{
      fill: #7FFF00;
}


It didn't work. Can anyone please help me to achieve this?
Hello,
I try to build a custom Apex class for my search component. I get multiple errors and dont know how to fix them. Can you help me with the adjustment?

Greetings Jonathan

User-added image
I have a class and I am trying to write a test class for it here is the code:
global class BatchMassDeleteDraftCaseRecs Implements Database.batchable<sobject>{
    
    global BatchMassDeleteDraftCaseRecs(){
         
    }
    global Database.QueryLocator start(Database.BatchableContext BC){
        
        String statusDraft = 'Draft';
        String statusNew = 'New';
        String statusClosed = 'Closed';
        return Database.getQueryLocator('SELECT Id, Status FROM Case WHERE (Status = :statusDraft OR Status = :statusNew OR Status = :statusClosed) and FileUploadFlag__c =true');
    }
    global  void execute(Database.BatchableContext BC,List<SObject> scope){
        delete scope;
    }
    global void finish(Database.BatchableContext BC){
    }
}