• Roshan 10
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 14
    Questions
  • 10
    Replies
Please find the sample code below. Thank you for helping me on this

ex:The console.log for data from getCaseRTByDeveloperName:{data: "{"Support":"Id1","Suggestion","Id2"}", error: undefined}.
I am trying to extract the keys returned by Apex (Support, Suggestion)            


--- Apex

public with sharing class CreateCaseHelper {

@AuraEnabled(cacheable=true)    
public static String getCaseRecordTypeDeveloperNameMap(){

    Map<String, Id> psdCaseRTDeveloperNameMap = new Map<String, Id>();

    for(RecordType rt : [Select Id, developername from RecordType 
    where SobjectType = 'Case']){

        psdCaseRTDeveloperNameMap.put(rt.developername, rt.Id);

    }

    return JSON.serialize(psdCaseRTDeveloperNameMap);


}

}

--- LWC HTML

<template>

    Suggestion Case Record TypeId:
    
</template>

---- LWC JS

import { LightningElement, api, track, wire } from "lwc";
import {
  getObjectInfo,
  getPicklistValues,
  getPicklistValuesByRecordType
} from "lightning/uiObjectInfoApi";

import CASE_OBJECT from "@salesforce/schema/Case";

import getCaseRTByDeveloperName from '@salesforce/apex/CreateCaseHelper.getCaseRecordTypeDeveloperNameMap';

export default class CaseTestLWC extends LightningElement {

    @track suggestionCaseRecId = "";


    @wire(getPicklistValuesByRecordType, {
        objectApiName: CASE_OBJECT,
        recordTypeId: "$suggestionCaseRecId"
      }) wiredRecordTypeSuggInfo({ data, error }) {
          if(data){
              console.log("data from getPicklistValuesByRecordType: " , data);
          }
      }
    
    
    @wire(getCaseRTByDeveloperName)
    caseRTByDeveloperName(data, error){
    if(data){
      console.log("data from getCaseRTByDeveloperName:", data);
      
      let p = data;
      for(let i in Object.entries(p)){
        
        var key = Object.entries(p)[i][0];
        var value = Object.entries(p)[i][1];
        console.log('key['+i+']='+key+' '+'value['+i+']='+value);
      }

    }else if(error){
      console.log("Error Occured while geting case record types ---> " + error);
    }
    
    }


}

---- LWC Meta

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
    <masterLabel>Create Case Test LWC</masterLabel>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
    </targets>
</LightningComponentBundle>
 
Looking for some help on implementing Email Translations in Salesforce (ex: Send Email on case creation). Also please advise if below understanding about creating email templates is correct

I have created some emails using classic Email Templates (Template Type: Custom) and most of the email is HTML with some merge fields from Case object. The emails are triggered from Workflows and Process Builders and Flows. The initial implementation was for English only and Emails need to be sent to Case Contact.

Now I need to implement it for other languages as well.

I started exploring options and this is where I am 

Emails from Apex - Can create multiple templates for each language and use Apex to send the emails but there is a limit of 5000 singleemail send (cannot send emails to more than 5000 emailaddresses per day). So felt Apex is not a good option

Emails using Visualforce - This seemed like a good option as I can specify the language and use custom labels to store translations. If everything works out, I should be able to acheive all translations with one email template. The main issue is with RefID. Looks like RefID cannot be referenced in Visualforce templates and having a formula field to calculate the RefId has its drawbacks. Also looks like in Winter '22 RefID will be disabled and we need to use the MessageID. Currently MessageID does not work for emails going out using Workflows and Process Builders

Emails using Custom Template Type - This is my current Email type. I can use custom Labels and should be able to achieve all translations with one email template.
The main issue, I noticed here is that I cannot specify the language of the email. 
If a workflow sends out the email, the language of the email is the language of the user that triggered the DML/workflow (there could be scenarios where the language of the user that triggered the workflow and the contact can be different)
The main issue with Email-to-Case. A case created with Email-to-Case is created with a default user with language english but the contact will be of different language

Thank you for your help
Hi,

On my case record in community, I want to prevent the user from updating the case by editing the Status field. The user should be able to close the case with the click of a custom button

Appreciate if anyone can provide their ideas
 
RefreshApex is calling ApexMethod but the contents of wire function (wiredDisableButton) are not executed.
First time when user clicks the updateCase button the Apex method returns true and case is updated. When the user clicks the updateCase button second time, the Apex method returns false
I see the Apex is executing but not able to figure out why the contents within wiredDisableButton are not being executed.
The posts I have seen so far mentioned that this is expected when the return value of the Apex method does not change this happens but in my case the return value is changed and I can see in the debug log

Thank you for looking into it

 
@track wiredActivities; //tried without @track as well

	//wired function
    @wire(isCaseClosed, {recordId: '$recordId'})
    wiredDisableButton(value){

        this.wiredActivities = value;
        const { data, error } = value;
        if(data){
            console.log('wiredDisableButton success =>', data);
            this.isClosed = data;
          
        }else if(error){
            console.error('wiredDisableButton error => ', JSON.stringify(error));
        }

    }
	
	//javascript function
	    updateCase(){
        
        refreshApex(this.wiredActivities);		

        if(this.isClosed == false){
		//show Info message
		}else{
		//update the record so that Case.isClosed = false;
		}
		
	//Apex function
	@AuraEnabled(cacheable=true)
    public static Boolean isCaseClosed(Id recordId){
	
	return true or false based on certain standard and custom fields
	
    }


 
I would like to explore the option of sending email through Apex. I was reading through the Messaging.SingleEmailMessage class. Can we specify setTemplateId and then modify the contents of the template before sending
I am planning to have placeholder text in the template and before sending I would like to modify it in Apex
 
For ex: On case detail page, when status value is changed (status is present in Record Detail component) and I need to detect that in my LWC component
I would like to know if it is possible to add custom styling to lightning-file-upload LWC
I have installed Apex PMD extension in my VSCode. I see a warning message about cognitive complexity and would like to know if there are any articles with examples specific to APEX on how to reduce the complexity
This is the link for the documentation for <lightning:recordForm> 
https://developer.salesforce.com/docs/component-library/bundle/lightning:recordForm/documentation

The example shows how to get the record Id using event.getParam("id") in the handleSuccess JavaScript function.
How can I get the inserted record.
for ex: If I am creating a new Account record how can I get that entire record so that I can directly pass it to an event attribute
I am trying to update 1300 Accounts and we are getting CPU Time Limit Exceeded Error.

We have a custom Trigger (CT) and a managed package Trigger (MT)
I was trying to find the root cause and I have turned OFF the managed package code and all validation rules, workflows and process builder

So I only have the custom Trigger active but all the methods inside it are commented. I noticed that even though there is no code executing, 3000 ms of CPU time is consumed for update of 1300 Accounts

I tried to just query the 1300 Accounts and without any DML I do not see any CPU Time being consumed (which is as per documentation)

I logged a case with Salesforce but there are asking me to move the code to Batch APEX. 

If 30% of the CPU Time is consumed without any code, I will have very little room for any custom code (considering the workflows and validation rules)

Any thoughts on how to handle this

Thanks,
Roshan
I would like to know what metadata will be present in a scratch org? Is it the Org that we designate as DevHub?
I am trying to create a trigger on Contact. When a custom field Company_Name__c on Contact is populated the trigger should create an Account if it does not exist. Also the AccountId should be updated on the Contact record
I was able to do it with simple trigger code but noticed that there is a limit (Number of Query Rows: 50000). So I started trying using Queueable APEX but ran into this issue
I am not able to update the Contact records. I see the AccountId value in the debug logs but the Contact record is not updated with AccountId after the Trigger completed
Can you suggest how this can be achieved

Below is the code I am using

CreateAccountFromCompanyTrigger

trigger CreateAccountFromCompanyTrigger on Contact (before insert, after insert) {
    If(Trigger.isBefore && Trigger.isInsert)
    {
       
    //ContactTriggerClass.InsertContacts(Trigger.new); 
    ContactTriggerClass CreateContactJob = new ContactTriggerClass(Trigger.new);     
    System.enqueueJob(CreateContactJob);
               
    }//If
}

ContactTriggerClass

public class ContactTriggerClass implements Queueable  {
  
    //public List<Contact> TriggeredContactList = new List<Contact>();
    public List<Contact> TriggeredContactList;
   
    public ContactTriggerClass(List<Contact> ContactList){
        TriggeredContactList = ContactList;
       
    }//mainmethod
   
    public void execute(QueueableContext context) {
    List<Account> AcctsToCreate = new List<Account>();
    Map<String, Account> AllAccountsMap = new Map<String, Account>();
       
        for(Account acct : [Select Id, Name from Account]){
            AllAccountsMap.put(acct.Name, acct);
           
        }
   
    System.debug('AllAccountsMap:' +AllAccountsMap.size());
       
        Set<String> CompanyNameSet = new Set<String>();
        for(Contact cntct : TriggeredContactList ){
            if(!AllAccountsMap.containsKey(cntct.Company_Name__c))
                CompanyNameSet.add(cntct.Company_Name__c);
        }   
       
         if(CompanyNameSet.size() > 0){
            for(String CompanyName : CompanyNameSet)
            AcctsToCreate.add(new Account(Name = CompanyName));
        insert AcctsToCreate;
        }
       
        if(AcctsToCreate.size() > 0)
        {
            for(Account acct : AcctsToCreate)
                AllAccountsMap.put(acct.Name, acct);
        }
        System.debug('UpdatedAccountsMap' +AllAccountsMap.size()); 
       
        for(Contact cntct : TriggeredContactList){
            cntct.AccountId = AllAccountsMap.get(cntct.Company_Name__c).Id;
            System.debug('cntct record:' +cntct +cntct.AccountId);
        }
       
       
}//execute
  
   
   
}//class
 
List<Id> accountIds = [Select Id from Account];

Run the above code in Execute Anonymous window and I am receiving the above error.
Can you please help me understand why this error is occuring or how I can overcome this error
We built an interface between Oracle and SFDC using Informatica Powercenter for inserting data into a Custom object

We received this error. However this error is captured in Informatica 
SFDC_31203 [FATAL] A fault is received in a create request.  Fault code [].  Fault subcode [].  Reason [Connection timed out.].  Detail [].

Will SFDC not capture such connection timeouts?
The debug levels details we used are 
Category Level
Database FINEST
System DEBUG
I would like to know what metadata will be present in a scratch org? Is it the Org that we designate as DevHub?
Hi,

I have tried to reset the password of sandbox, but not getting the password reset link on admin's mail ID. What can i do to login?
Can we delete files attached in contact related list, if a field is checked to true i want my file to get deleted in the related list, Is it possible?
  • February 18, 2021
  • Like
  • 0
Hi,

On my case record in community, I want to prevent the user from updating the case by editing the Status field. The user should be able to close the case with the click of a custom button

Appreciate if anyone can provide their ideas
 
RefreshApex is calling ApexMethod but the contents of wire function (wiredDisableButton) are not executed.
First time when user clicks the updateCase button the Apex method returns true and case is updated. When the user clicks the updateCase button second time, the Apex method returns false
I see the Apex is executing but not able to figure out why the contents within wiredDisableButton are not being executed.
The posts I have seen so far mentioned that this is expected when the return value of the Apex method does not change this happens but in my case the return value is changed and I can see in the debug log

Thank you for looking into it

 
@track wiredActivities; //tried without @track as well

	//wired function
    @wire(isCaseClosed, {recordId: '$recordId'})
    wiredDisableButton(value){

        this.wiredActivities = value;
        const { data, error } = value;
        if(data){
            console.log('wiredDisableButton success =>', data);
            this.isClosed = data;
          
        }else if(error){
            console.error('wiredDisableButton error => ', JSON.stringify(error));
        }

    }
	
	//javascript function
	    updateCase(){
        
        refreshApex(this.wiredActivities);		

        if(this.isClosed == false){
		//show Info message
		}else{
		//update the record so that Case.isClosed = false;
		}
		
	//Apex function
	@AuraEnabled(cacheable=true)
    public static Boolean isCaseClosed(Id recordId){
	
	return true or false based on certain standard and custom fields
	
    }


 
This is the link for the documentation for <lightning:recordForm> 
https://developer.salesforce.com/docs/component-library/bundle/lightning:recordForm/documentation

The example shows how to get the record Id using event.getParam("id") in the handleSuccess JavaScript function.
How can I get the inserted record.
for ex: If I am creating a new Account record how can I get that entire record so that I can directly pass it to an event attribute
I am trying to create a trigger on Contact. When a custom field Company_Name__c on Contact is populated the trigger should create an Account if it does not exist. Also the AccountId should be updated on the Contact record
I was able to do it with simple trigger code but noticed that there is a limit (Number of Query Rows: 50000). So I started trying using Queueable APEX but ran into this issue
I am not able to update the Contact records. I see the AccountId value in the debug logs but the Contact record is not updated with AccountId after the Trigger completed
Can you suggest how this can be achieved

Below is the code I am using

CreateAccountFromCompanyTrigger

trigger CreateAccountFromCompanyTrigger on Contact (before insert, after insert) {
    If(Trigger.isBefore && Trigger.isInsert)
    {
       
    //ContactTriggerClass.InsertContacts(Trigger.new); 
    ContactTriggerClass CreateContactJob = new ContactTriggerClass(Trigger.new);     
    System.enqueueJob(CreateContactJob);
               
    }//If
}

ContactTriggerClass

public class ContactTriggerClass implements Queueable  {
  
    //public List<Contact> TriggeredContactList = new List<Contact>();
    public List<Contact> TriggeredContactList;
   
    public ContactTriggerClass(List<Contact> ContactList){
        TriggeredContactList = ContactList;
       
    }//mainmethod
   
    public void execute(QueueableContext context) {
    List<Account> AcctsToCreate = new List<Account>();
    Map<String, Account> AllAccountsMap = new Map<String, Account>();
       
        for(Account acct : [Select Id, Name from Account]){
            AllAccountsMap.put(acct.Name, acct);
           
        }
   
    System.debug('AllAccountsMap:' +AllAccountsMap.size());
       
        Set<String> CompanyNameSet = new Set<String>();
        for(Contact cntct : TriggeredContactList ){
            if(!AllAccountsMap.containsKey(cntct.Company_Name__c))
                CompanyNameSet.add(cntct.Company_Name__c);
        }   
       
         if(CompanyNameSet.size() > 0){
            for(String CompanyName : CompanyNameSet)
            AcctsToCreate.add(new Account(Name = CompanyName));
        insert AcctsToCreate;
        }
       
        if(AcctsToCreate.size() > 0)
        {
            for(Account acct : AcctsToCreate)
                AllAccountsMap.put(acct.Name, acct);
        }
        System.debug('UpdatedAccountsMap' +AllAccountsMap.size()); 
       
        for(Contact cntct : TriggeredContactList){
            cntct.AccountId = AllAccountsMap.get(cntct.Company_Name__c).Id;
            System.debug('cntct record:' +cntct +cntct.AccountId);
        }
       
       
}//execute
  
   
   
}//class
 
We built an interface between Oracle and SFDC using Informatica Powercenter for inserting data into a Custom object

We received this error. However this error is captured in Informatica 
SFDC_31203 [FATAL] A fault is received in a create request.  Fault code [].  Fault subcode [].  Reason [Connection timed out.].  Detail [].

Will SFDC not capture such connection timeouts?
The debug levels details we used are 
Category Level
Database FINEST
System DEBUG