• Arun Kumar 1141
  • SMARTIE
  • 1455 Points
  • Member since 2023

  • Chatter
    Feed
  • 42
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 556
    Replies

Hello Everyone,
I need to pass dynamic data -id to this.template.querySelectorAll("lightning-input-field[data-id= 'accountId']"); 

for (let i = 0; i < this.accounts.length; i++) {
var accountId = this.accounts[i].Id;
 const temp =   this.template.querySelectorAll("lightning-input-field[data-id= 'accountId']");
               console.log('temp',temp[2]);
               temp[2].value = dateToday.toJSON().slice(0, 10);
}
// var accountId is not working here
accountId is not working here but if i pass hard coded id like 
const temp = this.template.querySelectorAll("lightning-input-field[data-id= '0069I000003OWmc']");
 
html 

    <lightning-input-field 
                                                        field-name="Year_Months_To__c"
                                                        variant= "label-hidden"
                                                        data-id={acc.Id} 
                                                        value={yearsMonthsTo}
                                                        onchange={handleDateTo}
                                                        required> 
     </lightning-input-field>

Please help me on the same. Thanks in advance
I am new to LWC and trying to fetch the records in the Lightning Datatable, which is working fine. After that i am trying to insert a record into the same using the record edit form and using refreshApex to display the inserted record immediately.
Can someone help me with the same?
PFA the code snippet for the same
@wire (getAccData,{recordId: '$recordId'})
    getAccTable({data, error}){
        if(data){   
            this.tableData = data;
        }
        else{
            console.log(error);
        }
    }

Here, i am storing the data returned from apex in tableData and then calling the same table data in refreshApex. But it's not working.

handleSave(){
        insertAcc({name : this.name})
        .then((result) => {
          this.result = result;
          return refreshApex(this.tableData);
        })
        .catch((error) => {
          this.error = error;
        });
    }
Hello, I have a question. Can I modify the order of list views, I mean the list views within this box, in Salesforce?sample
Hello, 

I'm building a flow and i need to strip an ID from a response.  Could someone help me with a formula that will take this text...

{"data":425478,"responseId":"154b3a3447a0","timeStamp":"2023-06-21T17:56:13.6865742+00:00","httpStatusCode":201,"isOk":true,"messages":[{"httpStatusCode":201,"messageCode":"CREATED","title":"Item was created","detail":"Call Report 425478 created","isOk":true}],"maxMessageIndex":0,"_v":"AD"}

...and return only the 6 digit ID from after the "data": 

So in the above example i would want 425478 returned only. 

Thanks in advance!  
 
Hi together,
I am trying to build a report of leads or contacts who have responded in form of an email/LI message or answered a cold call, without any follow-ups or activity by my side.

How would you go on on creating this report and which fields to use?
List<Account> accountstoUpdate = new List<Account>();
For(Account thisAccount : [Select id, Status FROM Account LIMIT 50000]){
ThisAccount.Status = ‘Active’;
AccountsToUpdate.add(thisAccount);
}
try{
Database.update(AccountstoUpdate,false);
}catch (Exception e){
System.debug(e.getMessage());
}
If I have UserRole Name , then how to fetch ID for it in Apex. This is not for current user info

I came across an error in which I got in a record triggered flow Too many SOQL Queries). It is a. In which a "get record" element which queries contacts by comparing the ids present in another list and having couple of other conditions which checks whether some fields should not be null. The flow element is not present in any loops. can you please tell me in which other direction i can look to solve this issue
i have a custom button in campaign object related list of campaignmember object and I need to call vf page that will bring the campaign record id using the custom button.

I have a requirement I want to Count all total case records and count of Which case status was New
Hi all.

I have a problem trying to pass the (Account) recordId from the Lightning page to an LWC to an Apex class.

This is a line chart I plan to show in the Account detail page, but I am unable to pass the record Id from the page to LWC to Apex class. The LWC is used in a screen flow. In the Lightning page I pass the record Id.

JS:
import {LightningElement, wire, track, api} from 'lwc';
    import { getRecord } from 'lightning/uiRecordApi';
    import getEstosDatos from '@salesforce/apex/BC_PuntajeActor3valores.getEstosDatos';
    export default class BC_PuntajeActor3valores extends LightningElement {
        @api recordId;
        @track chartConfiguration;
        @track data;
        @wire(getEstosDatos , { recordId: "$recordId"})
        WireGetEstosDatos({error, data}) {
            if (error) {
                this.error = error;
          console.log('error => ' + JSON.stringify(error));
          this.chartConfiguration = undefined;
            } else if (data) {
                    let chartData = []; 
(...)

Apex class:
 
public class BC_PuntajeActor3valores {
    @AuraEnabled(cacheable=true)
    public static List<BC_Puntaje_semanal_actor__c> getEstosDatos(String actorId){
        return BC_PuntajeActor3valores.obtenerDatosGrafico(actorId);
    }
    
    @RemoteAction
    public static List<BC_Puntaje_semanal_actor__c> obtenerDatosRemotos(String actorId){
        return BC_PuntajeActor3valores.obtenerDatosGrafico(actorId);
    }
    
    public static List<BC_Puntaje_semanal_actor__c> obtenerDatosGrafico(String actorId){
        List<BC_Puntaje_semanal_actor__c> estosDatos = new List<BC_Puntaje_semanal_actor__c>();
        idActor=id.valueof(actorId);
        estosDatos = [select id, BC_Fecha__c, BC_Puntaje__c, BC_Orden__c from BC_Puntaje_semanal_actor__c where BC_Actor__c =: idActor order by BC_Orden__c];
        system.debug(estosDatos);
        return estosDatos;
    }
}


Note that if I change the 
@wire
line to
@wire(getEstosDatos , { recordId: "001H..."}) // this is an actual account record Id.
it does the trick (so I understand all the logic works, except that I'm unable to pass the record Id from the page to the LWC to the class).

Any help would be greatly appreciated!

Thx​​​​​​​
i have opened two pop up modal with the help of LWC components and want to close automatically first modal pop up .Can you any one help of this scenario.
I am facing the above issue when runnig the batch class, Any inputs will really help 

            //creating accounts 
            for(Account pacc :personAccountlist ){
                if (String.isNotBlank(pacc.Location_Name__pc) && String.isNotBlank(pacc.CT_Employee_ID__c)){
                    string locName =  pacc.Location_Name__pc.toUppercase().contains('TELEWORKER') ? 'Memorial sloan kettering - Teleworker' :'Memorial Sloan Kettering - '+ pacc.Location_Name__pc;
                    if(locationAccountMap.get(locName)==Null){
                        Account newAc = new Account();
                        newAc.Name = 'Memorial Sloan Kettering - '+ pacc.Location_Name__pc;
                        newAc.RecordTypeId=accountObjRecordTypeId;
                            newaccountMap.put(newAc.Name,newAc);
                                        
                    } 
                }
            }
            if(newaccountMap.size()>0){
                insert newaccountMap.values();
            }
            
Hello,
In the formula below, I would like the outcome of the Formula to enter the correct image into the Deal Approval Required field. Green, Blue, Yellow, etc. The first part of the formula is working as expected, so Approval Not Required is being entered if amount >7500 is working, but rest of the formula is not working correctly. Any ideas or suggestions would be appreciated. Thanks.  

IF(
    SBQQ__NetAmount__c > 7500, 
    "Approval Not Required",
    IF(
        SBQQ__NetAmount__c <= 7500 && ISBLANK(CPQ_Approval_Level_MAX__c), 
        "Approval Required ",
        CASE(
    CPQ_Approval_Level_MAX__c,
    1, IMAGE('https://jmpsoftware--main2--c.documentforce.com/servlet/servlet.ImageServer?id=0155b000006hl9z&oid=00D8K0000004cJ1&lastMod=1652276904000', "Green"),
    2, IMAGE('https://jmpsoftware--main2--c.documentforce.com/servlet/servlet.ImageServer?id=0158K0000000Xrs&oid=00D8K0000004cJ1&lastMod=1652276872000', 'Blue'),
    3, IMAGE('https://jmpsoftware--main2--c.documentforce.com/servlet/servlet.ImageServer?id=0155b000006hl9y&oid=00D8K0000004cJ1&lastMod=1652276772000', 'Yellow'),
    4, IMAGE('https://jmpsoftware--main2--c.documentforce.com/servlet/servlet.ImageServer?id=0155b000006hlA0&oid=00D8K0000004cJ1&lastMod=1652276863000', 'Red'),
    5, IMAGE('https://jmpsoftware--main2--c.documentforce.com/servlet/servlet.ImageServer?id=0155b000006hl9x&oid=00D8K0000004cJ1&lastMod=1652290642000', 'Black'),
    "N/A"
)
    )
)
Hello,
I get following error UpdateOverdueTasksCount: System.LimitException: Too many SOQL queries: 101 for this Trigger: 

// Every time a Task is created or updated,
// update the 'No of Overdue Tasks' in the Account object

trigger UpdateOverdueTasksCount on Task (after insert, after update) {
    for (Task myTask : Trigger.new) {
        String accid = myTask.AccountId;
        List<Task> task = [SELECT Id FROM Task WHERE isDeleted = FALSE AND activitydate < TODAY AND isclosed = FALSE AND AccountID = :accid];
        List<Account> account = [SELECT Id FROM Account WHERE Id = :accid];
        if (account.size() >0) {
            account[0].No_of_Overdue_Tasks__c = task.size();
            update account[0];
        }
    }
}

I don't know how to program. Could someone please help me what I need to change in this code to eliminate this error?

Thanks!
Monika

Hello Everyone,
I need to pass dynamic data -id to this.template.querySelectorAll("lightning-input-field[data-id= 'accountId']"); 

for (let i = 0; i < this.accounts.length; i++) {
var accountId = this.accounts[i].Id;
 const temp =   this.template.querySelectorAll("lightning-input-field[data-id= 'accountId']");
               console.log('temp',temp[2]);
               temp[2].value = dateToday.toJSON().slice(0, 10);
}
// var accountId is not working here
accountId is not working here but if i pass hard coded id like 
const temp = this.template.querySelectorAll("lightning-input-field[data-id= '0069I000003OWmc']");
 
html 

    <lightning-input-field 
                                                        field-name="Year_Months_To__c"
                                                        variant= "label-hidden"
                                                        data-id={acc.Id} 
                                                        value={yearsMonthsTo}
                                                        onchange={handleDateTo}
                                                        required> 
     </lightning-input-field>

Please help me on the same. Thanks in advance
trigger OpportunityTrigger on Opportunity (after insert, after update, after delete, after undelete) {
       
    set<Id> accIds = new set<Id>();
    
      if(trigger.isAfter && trigger.isInsert){
        
        for(Opportunity opp : trigger.new){
            
            if(opp.AccountId != null){
                
                accIds.add(opp.AccountId);
            }
        }
    }
    if(trigger.isUpdate && trigger.isUpdate){
        
        for(Opportunity opp : trigger.new){
            
            if(opp.AccountId != Trigger.oldMap.get(opp.Id).AccountId){
                
                accIds.add(opp.AccountId);
                accIds.add(Trigger.oldMap.get(opp.Id).AccountId);
            }
        }
    }
    
    if(trigger.isAfter && trigger.isDelete){
        for(Opportunity opp : trigger.old){
            if(opp.AccountId != null){
                accIds.add(opp.AccountId);
            }
        }
    }
   
  
         List<AggregateResult> aggrList = [Select Name, AccountId, MAX(Amount) maxAmt from Opportunity
                                          where Amount!=null and AccountId IN: accIds
                                          group by Name, AccountId ORDER BY MAX(Amount) desc limit 1];
        
            List<Account> accList = new List<Account>();
            for(AggregateResult aggr: aggrList){
            Id accId = (Id) aggr.get('AccountId');
            String oppName = (String) aggr.get('Name');
            Decimal maxOppAmount = (Decimal) aggr.get('maxAmt');
            Account acc = new Account(Id= accId,HighestOppAmount__c=oppName);
            accList.add(acc);
        }
        if(accList.size() > 0){
            update accList;
        }
    }
Delete and insert is working fine but I am not getting why my update is not working please check this code 
public class updateHandler {
    
    public static void updateaccHandler(list<account> upac, map<ID, account> mapaccmap){
               
             for(account acc : upac){
                 if(acc.phone != mapaccmap.get(acc.ID).Phone){
                     acc.description = 'Phone is updated  , old phone mumber is'+ acc.mapaccmap.get(acc.ID).phone +' & new phone is :'+ acc.phone;
                                        
                                        
                 }
             }
    }

}
Can you help me wirte a handler class for the below senario

            5. On account record deletion store that record in Backup object.

Create a new object Backup. In that create Long Text field - Record Backup.

Only those fields that have values must be saved in this with their fieldname and fieldvalue, also save Name of user who created this record and with createddate, lastmodified date.Each field value must start on new line.




trigger createBackup on Account (after delete) 
{
 if(trigger.isDelete && trigger.isAfter)
 {
  List<My_Backup__c> lstToInsrt = new List<My_Backup__c>();  
  for(Account deletedAcc : trigger.old)
  {
   system.debug('deletedAcc '+deletedAcc );
   My_Backup__c backup = new My_Backup__c();
   backup.Name = deletedAcc.name;
   lstToInsrt.add(backup);
   system.debug('backup '+backup);
  }
  if(lstToInsrt.size()>0)
  {
   insert lstToInsrt;
   system.debug('list'+lstToInsrt);
  }
 }
}
Hi Everyone,

Can you help be with the below code:
1. Create an Account Record with Name =”Eternus”. Create associated contacts. Create a Custom field called Contact Count on Account . Query on Contact
where Account.Name =”Eternus” and count the associated contacts. Update the custom field on Accounts with that count..

I am not getting the count of the records:

public class Accassoccon {
    public static void accountacc(){
        Account a = new Account();
        a.Name = 'Eternus';
        Database.insert(a,false);
        system.debug('The inserted account is:' +a);
       list<Account > recordIDs = new   list<Account >();
List<Account> accountlist1 = [Select Id, ContactCount__c, (Select Id From Contacts) From Account where Id =: recordIDs];  //get a list of the corresponding accounts
for(Account account : accountlist1) {
    
    if(account.Contacts == null) continue;
    
    account.ContactCount__c = account.Contacts.size();
}

Database.update(accountList1,false);        
    }

}

Hello,

I am facing Unable to lock row when I am updating hierarchical custom settings that is being updated in trigger(On Contact Object) context. This error I am getting when I am importing Contacts from Import wizard.
I am trying to import around 2000 records.

Thanks in advance.

Flow & Trigger are created on same object, how to avoid recursion. pleae explain this proivde the solution?
Hi all, I am trying to create a validation rule to ensure a DATE field is populated if the pick list value of another field is set to certain value.  here is what I have and the error that I am getting:

AND(ISPICKVAL (Stage__c ="Scheduled"),ISBLANK(Scheduled_date__c =""))

Error: Error: Field Stage__c is a picklist field. Picklist fields are only supported in certain functions

 
Create a future method to calculate total number of contacts under each account and update it in the account custom field names as number of contacts field, implement this using future method.
 
I have a formula field and I have a picklist field called stagename, it has  5 single vaues 
the formula field should get value of  Account.Account_FY_Franchis__c (field from account)
only when the stagename is "1" or "2"  for other stagenames this formula field should not change , is it possible?
thanks
This is my first validation rule :
AND(
RecordType.DeveloperName = 'Final_Custom_Config',
$User.Bypass_Validation__c = False,

OR(
IF(
NOT(
OR(
ISPICKVAL(OTP_Protocol_Slot_1__c ,'Yubico OTP w/Yubicloud'),
ISPICKVAL(OTP_Protocol_Slot_1__c ,'OATH/HOTP w/Symantec VIP'),
ISPICKVAL( OTP_Protocol_Slot_1__c , 'None')
)
),
IF(ISBLANK(Public_PGP_Key__c), TRUE, FALSE), FALSE
),

IF(
NOT(
OR(
ISPICKVAL( OTP_Protocol_Slot_2__c ,'Yubico OTP w/Yubicloud'),
ISPICKVAL( OTP_Protocol_Slot_2__c ,'OATH/HOTP w/Symantec VIP'),
ISPICKVAL( OTP_Protocol_Slot_2__c , 'None')
)
),
IF( ISBLANK( Public_PGP_Key__c ) , TRUE , FALSE), FALSE
)
)
)

This is my second validation rule:
and( Batch_Master_Key_BMK_provided__c = true, Public_PGP_Key__c = NULL)


I have to combine the second VR into first in such a way that both VR should work. 
Hello. Is there any way to simplify this formula using BLANKVALUE function instead ISPICKVAL and nested IF?
IF(NOT(ISPICKVAL(Status, "Closed")), TODAY() - C4G_Project_Entry_Date__c,
IF(ISPICKVAL(Status, "Closed") && (NOT(ISBLANK(C4G_Project_Exit_Date__c))), C4G_Project_Exit_Date__c - C4G_Project_Entry_Date__c,
IF(ISPICKVAL(Status, "Closed") && (ISBLANK(C4G_Project_Exit_Date__c)),
DATEVALUE(ClosedDate) - C4G_Project_Entry_Date__c, null)))
The following code only shows Error 2. How can one modify it to show both errors (short of accumulating all errors and showing as one large string).

trigger testAccountError on Account (after insert) {


        for (Accout a: Trigger.New) {
            a.addError('Error 1');
            a.addError('Error 2');
        }

}
Unable to view Walkthrough Promots in salesforce . getting error as "You can't open the in-app guidance because it isn't available or you don't have access. Contact your Salesforce admin for help."