• veer soni
  • PRO
  • 2378 Points
  • Member since 2020
  • Developer
  • ACS


  • Chatter
    Feed
  • 79
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 0
    Questions
  • 354
    Replies
I have an Account with Name "ATALANTE".
When I do a SOSL Query with filter "ATALANTA", the account is still returned.
It looks like SOSL does not search only exact matches.
User-added image

Can someone explain this?
I cannot find any article or documentation that explains this behavior, and I need to provide official explanation to my client.

Thank you
Hi, I'm new to VSCode. Today I opened an existing project from my pc and tried to authorize the org, but couldn't find the option from the command palette. I've installed CLI ad Salesforce pack extensions. Please help. Thanks.Screenshot
Hi..,
Whenever i uploaded a new file doc related to Case record, i want to create new Task which needs to be assigned to Case Owner.
so, suggest me any ideas to fulfill this requirement.
Thanks.
Hi Folks,
I have stucked in an requirement.  I have a autolunched flow that update  Opportunity Type From Aura Component.
In Aura Component, I have a input field in which I put Opportunity Type Value and the moment I press the button my Aura component call to flow and update Opportunity Value.
Everything is working fine but problam is after flow finish, flow header and Finish Message show on screen Like Below.
User-added imageMy Requirment is that When I call to flow at that time the flow header and finish message should not show on screen. It will seem like Hide flow. I have found out on google but Didn't get any right way.can someone help me to solve it.

Here is my Lightning Code.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,
                            force:hasRecordId,lightning:availableForFlowScreens"
                access="global" >
    
    <aura:attribute name="oppType" type="boolean" /> 
    
    
    <lightning:flow aura:id="flowData" onstatuschange="{!c.statusChange}"/>
    
    
    <div>
                <lightning:input type="text" name="text" label="Opportunity Type" value="{!v.oppType}"/>
                <lightning:button label="Submit" name="next" variant="brand" onclick="{!c.handleNextStage}"/>
     </div>
    
    
</aura:component>
 
({
	handleNextStage : function(component, event, helper) {
       var flow = component.find("flowData");
         var inputVariables = [
             {
                name : "recordId",  
                type : "String",
                value : component.get('v.recordId')
             },
             
             {
                name : "OpportunityType",  
                type : "String",
                value :  component.get('v.oppType')
             },
             
              
           ];
            
            flow.startFlow("update_Opportunity_Type",inputVariables);
             component.set('v.oppType','');
            },
            
     
             
      statusChange : function (component, event) {
              
        if (event.getParam('status') === "FINISHED_SCREEN") {
             $A.get("e.force:refreshView").fire();
              
         }
    }
})

Your help will be appreciated.
Thanks In Advance
 
Hi All,

I have a field called order__c in quote and quote line item objects. Using trigger, I want to update order__c field in quote line item, when order__c field in quote is updated. 

Any Idea how to do this?

Thank you,
Kezia
I'm stuck with last unit of the project - create formula and roll-up summary field ...... in which when i copy the formula = ( VALUE(TEXT(Core_Competencies__c)) + VALUE(TEXT(Experience__c)) + VALUE(TEXT(Leadership_Skills__c)) + IF( Recommend_for_Hire__c , 5, 0) ) / 4 .... it is highlighting Recommend_for_Hire__C and mentioning the error - incorrect parameter type for function 'if()'. expected boolean received text.
Hi All,

I am trying to build a search component which takes multiple criteria so i am adding fields, criteria and the search string. When i try to add more than 1 criteria in my lightning component i am getting this error
"This page has an error. You might just need to refresh it. Action failed: c:FilterComponent$controller$searchProducts [Cannot read property 'get' of undefined] Failing descriptor: {c:FilterComponent$controller$searchProducts}"
Please help me fix this. I also tried checking if its an array or not but that doesn't work in my favour.
User-added image


 
Component :

<aura:component controller="SearchFilterController" Implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="prodWrapper" type="list"/>
    <aura:attribute type="Object" name="testAttribute" />
    <aura:attribute name="accountList" type="Account[]"/>
    <aura:attribute name="productFields" type="list"/>
    <aura:attribute name="criteriaType" type="list"/>
    <lightning:card>
        <div class="slds-m-around--xx-large">
            <div class="slds-float_right slds-p-bottom_small">
                <h1 class="slds-page-header__title">Add Row 
                    <lightning:buttonIcon iconName="utility:add"  size="large" variant="bare" alternativeText="Add" onclick="{!c.addRow}"/>
                </h1>
            </div>
            <div class="container-fluid">        
                <table class="slds-table slds-table_bordered slds-table_cell-buffer"> 
                    <thead>
                        <tr class="slds-text-title_caps">
                            <th scope="col">
                                <div class="slds-truncate">Sr. No</div>
                            </th>
                            <th scope="col">
                                <div class="slds-truncate" title="Field Name">Field Name</div>
                            </th>
                            <th scope="col">
                                <div class="slds-truncate" title="Criteria">Criteria</div>
                            </th>
                            <th scope="col">
                                <div class="slds-truncate" title="Value">Value</div>
                            </th>  

                            <th scope="col">
                                <div class="slds-truncate" title="Action">Action</div>
                            </th>
                        </tr>
                    </thead>   
                    <tbody>      
                        <aura:iteration items="{!v.prodWrapper}" var="acc" indexVar="index">
                            <!--{!v.prodWrapper.size} -->
                            <tr>
                                <td> 
                                    {!'index'+index}
                                </td>
                                <td>
                                    <!--<lightning:input name="fieldName" type="text" maxlength="50" value="{!v.testAttribute.fieldNames}" />
                                {!index}
									-->
                                     <lightning:select aura:id="PicklistId" label="Select a field" name="fieldName" onchange="{c.changeHandler}" >
                                                <option value="" text="- None -" /> 
                                                <aura:iteration items="{!v.productFields}" var="field">
                                                    <option value="{!field}" text="{!field}" />  
                                                </aura:iteration>
                                            </lightning:select>
								</td>
                                <td>
                                   <!-- <lightning:input name="criteria" type="string" maxlength="30" value="{!acc.criteriaType}" />
                                -->
                                    <lightning:select aura:id="PicklistId2" label="Select a criteria" name="criteria" >
                                                <option value="" text="- None -" /> 
                                                <aura:iteration items="{!v.criteriaType}" var="per">
                                                    <option value="{!per}" text="{!per}" />  
                                                </aura:iteration>
                                            </lightning:select>
								</td>
                                <td>
                                    <lightning:input name="searchFieldValue" type="text" value="{!acc.searchStr}" />
                                </td>
   
                                <td>
                                    <a onclick="{!c.removeRecord}" data-record="{!index}">
                                        <lightning:icon iconName="utility:delete" size="small" alternativeText="Delete"/>
                                        <span class="slds-assistive-text">Delete</span>
                                    </a>
                                </td> 
                            </tr>
                        </aura:iteration>
                    </tbody>
                </table>
                <div class="slds-align_absolute-center slds-p-top_small">
                    <lightning:button variant="brand" label="Submit" title="Brand action" onclick="{!c.searchProducts}" />
                </div>
            </div>
        </div>
    </lightning:card>
</aura:component>

==================

JS Controller :

({	
    doInit:function(component, event, helper) {
        
        var action = component.get("c.displayFieldsAndCriteria");
            
        action.setCallback(this, function(response) {
                //get response status 
                var state = response.getState();
                if (state === "SUCCESS") {
                    //set empty account list
                   var respValue=JSON.parse(response.getReturnValue());
                    component.set("v.testAttribute",respValue);
                    //var testValue = component.set("v.testAttribute",response.getReturnValue());
                    var respVal =response.getReturnValue();
                    //console.log('respVal >>> '+respVal);
                    console.log('v.testAttribute value >>>>'+respValue);
                    console.log('criteriaType value >>>>'+respValue.criteriaType);
                    console.log('searchStr value >>>>'+respValue.searchStr);
                   // console.log('fieldNames value >>>>'+JSON.stringify(respValue.fieldNames));
                    //console.log('respValue.fieldNames typeof >>>> '+typeof(respValue.fieldNames));
                    var result=respValue.fieldNames;
                    console.log('result stringified >>>>>> '+result.typeof);
                    component.set("v.productFields",respValue.fieldNames);
                    component.set("v.criteriaType",respValue.criteriaType);
                    /*var criteriaTypeVar= component.get("v.criteriaType");
                    console.log('criteriaTypeVar >>>> '+criteriaTypeVar[0]);
                    var productFieldsVar= component.get("v.productFields");
                    console.log('productFields >>>> '+productFieldsVar);*/
                    alert('data received from class');
                }
            }); 
            $A.enqueueAction(action);

    },
  	
    addRow: function(component, event, helper) {
        //get the List from component  
        var pwList = component.get("v.prodWrapper");
        
        //Add New criteria
        pwList.push({
            'fieldNames': '',
            'criteriaType': '',
            'searchStr': ''
        });
        component.set("v.prodWrapper", pwList);
    },
    
    removeRecord: function(component, event, helper) {

        var criteriaList = component.get("v.prodWrapper");

        var selectedItem = event.currentTarget;
        //Get the selected item index
        var index = selectedItem.dataset.record;
        criteriaList.splice(index, 1);
        component.set("v.prodWrapper", criteriaList);
    },
    
    changeHandler:function(component, event, helper){
    var count=event.target.id;
    console.log('input id >>>> '+count);
	},
    	
   searchProducts: function(component, event, helper) {  
       var a= component.get("v.prodWrapper");
       console.log(a);
        var fName=component.find("PicklistId").get("v.value");
        for(var i=0;i<a.length;i++){
            
                console.log('fName >>>>'+ fName.length);
                a[i].fieldNames=fName;
                console.log('a value >>>> '+JSON.stringify(a));
           
        }
         /*var b= component.find("PicklistId2").get("v.value");
            var c= component.find("PicklistId").get("v.value");*/
        // use compo.find.get for picklist fields and while setting parameters create a json string
        // send the created json string to server
          /*console.log('typeof c>> '+typeof(c) +' '+JSON.stringify(c));
        console.log('typeof b >> '+typeof(b) +' '+JSON.stringify(b));
       console.log('typeof a >> '+typeof(a) +' '+JSON.stringify(a));*/
        var action = component.get("c.generateQuery");
            action.setParams({
                "prodWrapList": JSON.stringify(component.get("v.prodWrapper"))
            });
        action.setCallback(this, function(response) {
                //get response status 
                var state = response.getState();
                if (state === "SUCCESS") {
                    //set empty account list
                    component.set("v.prodWrapper", []);
                    alert('data sent to generateQuery');
                }
            }); 
            $A.enqueueAction(action);
       
    }
})





 
I need to create a checkbox input field and link that to a custom field. As in whatever input we give in the checkbox, that value should be stored in a custom checkbox field. How can I do this?
Hello- I'm writing a scheduled Apex class that grabs all Accounts that are listed as 'Active' in a custom field, find's the most recent closed won Opportunity and passes a value from a lookup field on that opp back to another lookup on the Account. The class isn't flagging any problems for me, but throws an error when it tries to run upon being scheduled.

The error seems to indicate that it couldn't find any records to update. I verified that there are records that meet the criteria, and when I run the SOQL query in isolation it finds those records. When I try to debug it in the Execute Annonymous window, it also doesn't return any system.debug messages. I appreciate any help figuring out where I'm going wrong! 
The error:
Sandbox

Apex script unhandled exception by user/organization: 0053i000002hKdg/00D1g0000002qa7
Source organization: 00D3i000000ttF8 (null)
Scheduled job 'Se Update2' threw unhandled exception.

caused by: System.QueryException: List has no rows for assignment to SObject

Class.UpdateSEOnAccount.execute: line 8, column 1
The Apex Class:
global class UpdateSEOnAccount implements Schedulable{
    global void execute (SchedulableContext ctx){
        UpdateSE();
    }
    public void UpdateSE(){
        List<Account> Actlst = new list<account>();
        for(Account a : [SELECT Id FROM Account WHERE Customer_Status__c = 'Active']){    
             a.Sales_Engineer__c = [SELECT Id, SE__c, AccountId 
                          FROM Opportunity 
                          WHERE AccountId = : a.id AND StageName = 'Closed Won'
                          ORDER BY CloseDate DESC LIMIT 1].SE__c;
           system.debug('a is '+ a.Id);
           if(a.SE__c <> NULL){
           Actlst.add(a);
           }
            system.debug('size of list is '+ Actlst.size());
        }
        if(Actlst.size()>0){
            update Actlst;
        }
    }
}


 
1.   What if the master object has 20 roll-up summary fields and a new managed package installing has 10 roll-up summer fields on the same master object?? managed package install successfully or else??

2. how many roll-up summaries can be created per object this question is for ADM 201 because I read somewhere in enterprise edition we can only create 10 roll-up summary per custom object can someone clarify this for me please
global class CouponBatch implements Database.Batchable<sObject>, Database.AllowsCallouts{
    global Database.QueryLocator start(Database.BatchableContext bc){
        String soqlQuery = 'SELECT id, CouponCode__c, Redeemed_Code__c, Type From order';
        return Database.getQueryLocator(soqlQuery);
    }
     

    global void execute(Database.BatchableContext bc, List<Order> orderDetails){
         
                try {
                    HttpRequest req = new HttpRequest();
                    req.setEndpoint('callout:couponcode_101/couponcode.json');
                    req.setMethod('GET');
                    Http http =  new Http();
                    HttpResponse res = http.send(req);  
                        if (res.getStatusCode() == 200) {
                        Map<String, Object> results = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
                        List<Object> resultslist = (List<Object>)results.get('discount_codes');
                        for(order datadetails: orderDetails) {
                            for(Object mapa:resultslist ){
                                Map<String,Object> tempMap = (Map<String,Object>)mapa;
                                if(datadetails.CouponCode__c==tempMap.get('code')){
                                    datadetails.Redeemed_Code__c=true;                                   
                                }
    
                            }
                        }      
                       update orderDetails;        
                    }
                }
                catch(Exception e){
                     system.debug('Message: '+e.getMessage());
                        system.debug('Line: '+e.getLineNumber());
                }
            }
   
    global void finish(Database.BatchableContext bc){
     }
}
hello folks,
I have a requirment in which I want to show some fields of  object based on recordId.I am using Lightning:editForm but problam is that everytime all fields keep on edit mode. I can use Lightning:RecordForm but I have to show fields in section.

My Main Requirment is that when page will load at that time all fields will show on view mode and when user click on Edit  Icon at that time record turn in edit mode such as standard Record form but I have to show fields in section.
Can someone help me to achieve this requirment.
I will be grateful.
Thanks In Advance
Trigger:

trigger TriggerOnOpportunity on Opportunity (after update) {
       if(trigger.isafter && trigger.isupdate){
        TriggerHandlerOpportunity.createNewAFAO(trigger.new,trigger.oldmap);
            } 
    }

Apex Class:

public class TriggerHandlerOpportunity {    
    public static void createNewAFAO(List<Opportunity> oppList,map<id,Opportunity> oldMap){
        List<Opportunity> OpportunityList = new List<Opportunity>();
        for(Opportunity op:oppList){
            if(op.Opportunity_Type__c == 'AFAO' &&  (op.StageName == 'Closed Signed Up (Won)' &&  oldMap.get(op.id).StageName != op.StageName)){
                Opportunity newOpportunity = new Opportunity();
                newOpportunity.Name = op.name;
                newOpportunity.StageName = op.Stagename;
                newOpportunity.CloseDate = op.CloseDate;
                newOpportunity.AccountId = op.AccountId;
                newOpportunity.Opportunity_Type__c = op.Opportunity_Type__c;
                 OpportunityList.add(newOpportunity);
                    
            }
        }
        insert OpportunityList;
        
    }
}
 
Hi,

I have to write a trigger that when new contact is being created to populate the account domain field value in to contact domain field

Domain is a field created on account and contact field.

Please help.
The task is to create an Apex trigger that sets an account’s Shipping Postal Code to match the Billing Postal Code if the Match Billing Address option is selected. As per the task, I created the checkbox "Match Billing Account" on the Accounts Object first. Here is the code I used which seems to work for other users: 

trigger AccountAddressTrigger on Account (before insert, before update){
     for(Account account: Trigger.new){
        if((account.Match_Billing_Address__c==true)&&(account.BillingPostalCode != NULL)){    
       account.ShippingPostalCode = account.BillingPostalCode;  
            }
        } 
    }

The Error is as following: We updated an account that had 'Match_Billing_Address__c' set to false. We expected the trigger not to fire, but it did. Make sure the trigger fires only if 'Match_Billing_Address__c' is true.

I tried different Playgrounds but always end up with the same error. 
//Display.cls

public with sharing class Display {
    @AuraEnabled(cacheable=true)
    public static Integer total(String status){
        Return [SELECT COUNT() FROM Contract WHERE Status =: status];
    }
}




//displayTotal.html

<template>
    <lightning-card title="Total Contracts" >
        <div class="slds-m-around_medium">
            <template if:true={a.data}>
               <div class="data">
                {a.data}
               </div>
            </template>
            <template if:true={a.error}>
                <div class="data">
                    {a.error}
                   </div>                
            </template>
        </div>
        <footer>Loreum Ipsum picslum</footer>
    </lightning-card>
</template>



//displayTotal.js

import { api, LightningElement, wire } from 'lwc';
import total from '@salesforce/apex/Display.total'
export default class DisplayTotal extends LightningElement {
    @api Status;
    @wire(total,{status:'$Status'}) a;
    
}
 
getting error : This page has an error. You might just need to refresh it. Action failed: c:LightningHotelManCompo$controller$doSave [component is not defined] Failing descriptor: {c:LightningHotelManCompo$controller$doSave}

application :


<aura:application extends="force:slds" >
    <c:LightningHotelManCompo/>
</aura:application>
================================
component

<aura:component controller="LightningHotelManApex"
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name="Guesthotel" type="Guest_Master__c" default="{'sObjectType':'Guest_Master__c',
                                                                   'Guest_First_Name__c':'',
                                                                   'Guest_Last_Name__c':'',
                                                                   'Guest_Phone__c':'',
                                                                   'Guest_Email__c':'',
                                                                   'Number_of_Adults_12_yrs__c':'',
                                                                   'Number_of_Children_0_12_yrs__c':'',
                                                                   'Check_in_Date__c':'',
                                                                   'Check_Out_Date__c':'',
                                                                   'City_of_Hotel__c':'',
                                                                   'Preferred_Hotel_Type__c':''}"/>
    
    <div>
      <div class="slds-card">
          <div class="slds-p-around_medium">Please Enter Details</div>
      </div>

   </div>
    
    <div class="Container-fluid">
        <div class="form-group">
            <label> First Name </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_First_Name__c}"/>
        </div>
         <div class="form-group">
            <label> Last Name </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Last_Name__c}"/>
        </div>
         <div class="form-group">
            <label> Phone </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Phone__c}"/>
        </div>
         <div class="form-group">
            <label> Email </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Guest_Email__c}"/>
        </div>
         <div class="form-group">
            <label> Number of Adults(12+ yrs) </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Number_of_Adults_12_yrs__c}"/>
        </div>
         <div class="form-group">
            <label> Number of Adults(0-12 yrs) </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Number_of_Children_0_12_yrs__c}"/>
        </div>
         <div class="form-group">
            <label> Check in Date </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Check_in_Date__c}"/>
        </div>
         <div class="form-group">
            <label> Check out Date </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Check_Out_Date__c}"/>
        </div>
         <div class="form-group">
            <label> City of Hotel </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.City_of_Hotel__c}"/>
        </div>
         <div class="form-group">
            <label> Prferred Hotel Type </label>
            <ui:inputText Class="form-control" value="{!v.Guesthotel.Preferred_Hotel_Type__c}"/>
        </div>
    </div>
    
    <div class="col-md-4 text-center">
        <ui:button class="btn btn-default" press="{!c.doSave}"> Save </ui:button>
    </div>
</aura:component>
=============================================

controller

({
    doSave : function(component, event, helper) {
        console.log('create records');
        
       helper.helperMethodGuest(component);
        
    }
})
==========================================
helper

({
    helperMethodGuest : function() {
        
        console.log('create records in helper ');
        var varGuest = component.get("v.Guesthotel");
        var action = component.get("c.saveRecord");
        action.setParams({
            "guest" : varGuest
        });
            action.setCallback(this,function(response){
             var state = response.getState();
            
            if(state =="SUCCESSS"){
            
            var newEmptyGuest = {'sObjectType':'Guest_Master__c',
                                     'Guest_First_Name__c':'',
                                     'Guest_Last_Name__c':'',
                                     'Guest_Phone__c':'',
                                     'Guest_Email__c':'',
                                     'Number_of_Adults_12_yrs__c':'',
                                     'Number_of_Children_0_12_yrs__c':'',
                                     'Check_in_Date__c':'',
                                     'Check_Out_Date__c':'',
                                     'City_of_Hotel__c':'',
                                     'Preferred_Hotel_Type__c':''};
                         component.set("v.Guesthotel",newEmptyGuest);
                         alert('Record is create succesfully');
        
        
    }else if(state=="ERROR"){
    alert('Error is clling server side action');
    
    var ErrorDetails =response.getError();
    alert('Reason of error ='+ErrorDetails[0].message);
}
        });
        $A.enqueueAction(action);
        
    }
})
===================================
apex class

public class LightningHotelManApex {
    @AuraEnabled
    public static void saveRecord(Guest_Master__c guest){
        
        try{
            system.debug(' guest record ::'+guest);
            if(guest != null){
                insert guest;
            }
        }catch(Exception ex){
            
        }
    }

}
Hy experts,
I want to set a flow's variable value from process builder but I  am not able to find any way. could anyone tell me how to achieve this requirment.

Thanks In Advance
Hi, 

I have below Apex code to send notification to case owner when an Email is transferred from one case to another. This was working fine before enabling Enhanced Email feature. But once its enbled it's throwing below error -

EXCEPTION - SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, EmailMessageTrigger: execution of AfterInsert
caused by: System.NullPointerException: Attempt to de-reference a null object

public static String transferEmailsToTargetCase(Id originCaseId, Id targetCaseId, Set<Id> emailIds) {
        System.debug('** transferEmailsToTargetCase start **');
        Map<Id, EmailMessage> oldEmailId2newEmail = new Map<Id, EmailMessage>();
        Case originCase = [
            SELECT Id, CaseNumber, Subject,
                (SELECT Id, FromAddress, Incoming, ToAddress, Subject, TextBody, ParentId, BccAddress,
                    CcAddress, FromName, Headers, HtmlBody, MessageDate, ReplyToEmailMessageId,
                    Source_Case__c, Status
                FROM EmailMessages
                WHERE Id IN :emailIds)
            FROM Case
            WHERE Id = :originCaseId
        ];
        
        Case targetCase = new case();
        if(targetCaseId!=null){
            targetCase = [
                SELECT Id, ownerId, owner.email, owner.name, CaseNumber, Subject
                    FROM Case
                    WHERE Id = :targetCaseId
            ];
        }
       
        if(originCase.EmailMessages.isEmpty()) {
            return Label.No_emails_under_source_Case;
        }   

        for(EmailMessage em : originCase.EmailMessages) {
            EmailMessage emCloned = em.clone();
            emCloned.ParentId = targetCaseId;
            if(String.isBlank(em.Source_Case__c)) {
                emCloned.Source_Case__c = originCaseId;
            }
            oldEmailId2newEmail.put(em.Id, emCloned);
        }


        try {
            EmailMessageTriggerHelper.CHECK_EDIT_RIGHTS_ON_CASE = false;
            insert oldEmailId2newEmail.values();
            copyOverAttachmentsToNewEmail(oldEmailId2newEmail);
            EmailMessageTriggerHelper.ALLOW_DELETION = true;
            delete originCase.EmailMessages;
            
            //send email to new case owner to confirm emails moved
            if(targetCaseId!=null){
                //update URL for live
                string cssProdOrgURL = Org_Settings__c.getOrgDefaults().ORG_URL__c+'/';
                system.debug('cssProdOrgURL --'+ cssProdOrgURL);
                
                string emailBodyConfirmMove = '<html><head><style> table {font-family: arial, sans-serif;border-collapse: collapse;}td, th {border: 1px solid #dddddd;text-align: left;padding: 8px;}tr:nth-child(even) {background-color: #F1F1F1;}</style></head><body><p>Hi ';
                emailBodyConfirmMove+=targetCase.owner.name+',</p><br/><p>THIS IS A SYSTEM GENERATED EMAIL.</p><p>Please be advised that one or more emails have been moved to the ';
                emailBodyConfirmMove+='<a href="'+cssProdOrgURL+targetCase.id+'">'+targetCase.CaseNumber+'</a> Case, and it requires your review.</p><br/><p>Number of Emails: ';
                emailBodyConfirmMove+=originCase.EmailMessages.size()+'</p><p>Case Subject: ';
                emailBodyConfirmMove+='<a href="'+cssProdOrgURL+targetCase.id+'">'+targetCase.Subject+'</a></p><br/><table ><tr ><th>Subject</th><th>From Name</th><th>From Address</th><th>Message Date</th></tr>';
                
                for(EmailMessage emCloned :oldEmailId2newEmail.values()){
                    emailBodyConfirmMove+='<tr><td><a href="'+cssProdOrgURL+emCloned.id+'">'+emCloned.Subject+'</a></td>';
                    emailBodyConfirmMove+='<td>'+emCloned.FromName+'</td>';
                    emailBodyConfirmMove+='<td>'+emCloned.FromAddress+'</td>';
                    emailBodyConfirmMove+='<td>'+emCloned.MessageDate+'</td></tr>';
                    
                }
                emailBodyConfirmMove+='</table>';
                if(string.valueOf(targetCase.OwnerId).startsWith('005')){//owner is user not queue
                    List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();
                    Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
                    user targetOwner = [SELECT Id, email FROM user WHERE id=:targetCase.OwnerId AND email != null];
                    msg.setToAddresses(new List<String>{targetOwner.email});
                    msg.setHTMLbody(emailBodyConfirmMove);
                    msg.setSubject('Emails transferred to CASE -'+targetCase.CaseNumber);

                    lstMsgs.add(msg);
                    Messaging.SendEmailResult[] r = Messaging.sendEmail(lstMsgs);
                    
                }
            }
            
            
        } catch(Exception e) {
  system.debug('** EXCEPTION - '+e.getMessage());
            return e.getMessage();
        }
        
        return Label.Success_msg;
    }
  • September 24, 2021
  • Like
  • 0
Hey all,
I am having trouble understanding why this code is not bulkified? Can someone please help me understand why my senior said its not bulkified? Also, can someone please help me bulkify this trigger code? 
Its a simple trigger where I am sending an welcome email to the 'billing contacts' (role of the contact) when account is created. This billing contact is assoicated with this account
public static void sendWelcomeEmailforPartnerPlans(List<Account> accounts) {
        system.debug('inside Partner plan welcome email method');
        map<id,id> accBillContactId = new map<id,id>();
        OrgWideEmailAddress owa = [select Id, DisplayName, Address from OrgWideEmailAddress limit 1];
        List<String> corporateEmail = System.label.MBT_CorporateEmail.split(',');
        List<String> bccEmail = System.label.MBT_BccEmailForPartnerPlan.split(',');
        EmailTemplate welcomeEt = [SELECT Id, Subject, Body FROM EmailTemplate WHERE DeveloperName = 'MBT_WelcomeCallEmailAlert'];        
        List<String> emailList = new List<String>();
        List<Messaging.SingleEmailMessage> singleMailList = new List<Messaging.SingleEmailMessage>();
        List<Messaging.SendEmailResult> sendEmailResults = new List<Messaging.SendEmailResult>{};
		for(Account acc1:accounts){
            system.debug('accountid--'+acc1.Id);
            if(acc1.AcctSeed__Billing_Contact__c!=null){ 
                accBillContactId.put(acc1.Id,acc1.AcctSeed__Billing_Contact__c);
            }
        }
        List<Contact>  contacts = [SELECT id, Email from Contact where id in :accBillContactId.values() ];
        for (Contact con : contacts) {
            emailList.add(con.Email);
        }
        system.debug('email ids---'+emailList);
        for(Account acct : [SELECT id, Name, MBT_Plan_Name__r.Name, MBT_Plan_Name__c from Account where id in: accounts ]){
            system.debug(acct.MBT_Plan_Name__r.Name);
            if(acct.MBT_Plan_Name__r.Name=='Partner'){
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                email.setTargetObjectId(accBillContactId.get(acct.Id));
                email.setTemplateId(welcomeEt.Id);
                email.setOrgWideEmailAddressId(owa.id);
                email.setToAddresses(emailList);
                email.setCCAddresses(corporateEmail);
                email.setBccAddresses(bccEmail);
                singleMailList.add(email);
            }//end-if
        }//end-for
        if(singleMailList.size()>0){
            try{
                sendEmailResults= Messaging.sendEmail(singleMailList);
            }
            catch(System.EmailException ex){
                system.debug('email excepition-->'+ex.getMessage());
            }
            for(Messaging.SendEmailResult sendEmailResult: sendEmailResults) {
                if(sendEmailResult.isSuccess()){
                    system.debug('isSuccess welcome call---'+sendEmailResult.isSuccess());
                }else {
                    for(Messaging.Sendemailerror sendEmailError : sendEmailResult.getErrors()) {
                        system.debug('sendemail error--'+sendEmailError.Message);
                    }
                }
            }
        }
    }//end method

 
Trying to get all account ID's based on a list of contact ID's I have. Any example SOQL statements would be great. 

Thanks! 
We have a parent object ABC which has a checkbox parent checkbox , we have a child object obc which has a checkbox child checkbox .

child checkbox needs parent checkbox to be checked in order to be checked . 
The situation i have is when that is done we shld not allow the parent checkbox to be unchecked when trying to and should give an error.

 
I have an Account with Name "ATALANTE".
When I do a SOSL Query with filter "ATALANTA", the account is still returned.
It looks like SOSL does not search only exact matches.
User-added image

Can someone explain this?
I cannot find any article or documentation that explains this behavior, and I need to provide official explanation to my client.

Thank you
Hi All,
I am trying to make a VisualForce page that on Load it show a simple JS Toast..
But i am keeping getting the following error:

Uncaught ReferenceError: sforce is not defined
    at showToast

This is my Visual Force Page, what i am doing wrong?:

<apex:page standardController="Account" lightningStylesheets="true" >
    <script type="text/javascript">
        window.onload = showToast();
        function showToast() {
            sforce.one.showToast({
                "title": "Attenzione",
                "message": "Test Message.",
                "type": "warning"
            });
        }
        
    </script>
</apex:page>

Thanks for help :) really apprecciated.

I have a formula text field that looks up the Account_Owner_Role__c (text) from the Account record. 

I now need the formula to populate only if a text field on the Account contains "Hunter" 

This is what I've tried:

IF(
OR(
TEXT(Sales_Role__c)='Hunter - 1',
TEXT(Sales_Role__c)='Hunter - 2',
TEXT(Sales_Role__c)='Manager - Hunter 1')
),
Account_Owner_Role__c
))

 

Hi all,
I would like to make a query through a lightning component.
This component should have some input parameters like fields to choose/insert (SELECT), object selection/input (FROM), and maybe a where condition.

Then, I would like to display the query result in another page.

I don't know how to insert parameters in a lightning component, pass them to a controller and make a query.

Is that possible? Could you give me some advise?

Thank you very much, any help would be very appreciated.

Raul

 
I'm working on an autolauched flow and I need to pass a list of sobjects to an apex class. I manage to get a collection of records but it isn't the right type, I need it to be a List
Hi All,

I have an Arrey in lwc JS and have Wrapper class in apex and on click button event mapping array to List<WrapperClass> but in apex all the array variable shows as NULL.

e.g.
in JS
===========
var accData=[{Name:"Sanjiv",Lastname:"Kumar"}];

=============
In Apex:
Class WrapperClass{
public string firstName;
public string lastName;
}

@AuraEnabled
public static void callMe(List<WrapperClass> wrpList){
system.debug('FirstName :'+wrpList[0].firstName);
system.debug('LastName :'+wrpList[0].lastName);
}


********when I call apex method callMe  through JS and pass accdata (JS array) FirstName and LastName appeares as NULL but values are being passed from JS*******************




Thanks

 
Hi All,

I need help in below scenario.
I want to create list of Account (parent) first and then list of child contacts in Apex;

e.g.
I have Account A,B,C
Account  A has contactC1
Account B has contact C2
Account C has contact C3

now

first create Account and then Contact. 
I do not have any external id

so I want to kow that how we can achieve it in apex
Thanks
Hi All,

I was working on aura component specialist challenge however, faced problem in setting component attribute value in helper JS. Need help on how I can set Boat__c[] type attribute in BoatSearchResults component.
BoatSearchResults.cmp
<aura:component controller="BoatSearchResults" >
    <aura:attribute name="boats" type="Boat__c[]"/>
    <aura:attribute name="boatTypeId" type="Id" />
    <aura:attribute name="selectedBoatId" type="String" />
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:handler name="boatselect" event="c:BoatSelect" action="{!c.onBoatSelect}" />
    <aura:handler name="boatselected" event="c:BoatSelected" action="{!c.onBoatSelected}" />
    
    <aura:method name="search" action="{!c.doSearch}" description="Takes boatTypeId as input parameter"> 
        <aura:attribute name="boatTypeId" type="Id" /> 
    </aura:method>
    <lightning:layout horizontalAlign="space" multipleRows="true">
        <lightning:layoutItem size="9" padding="around-small">
            <aura:iteration items="{!boats}" var="boat">
                <c:BoatTile boat="{!boat}" selected="{!boat.Id == v.selectedBoatId ? true : false }"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

BoatSearchResultsController.js
({
    doInit : function(component, event, helper) {
        
    },
    doSearch : function(component, event, helper) {
        //debugger;
        var boatTypeId = component.get("v.boatTypeId");
        console.log('In boat search results 2 : ',boatTypeId);
        helper.onSearch(component, boatTypeId);
        console.log("Inside boat search results controller");
    },
    onBoatSelect : function(component, event, helper) {
        var boatId = event.getParam("boatId");
        console.log("onBoatSelect in BoatSearchResults.", boatId);
        component.set("v.selectedBoatId", boatId);
    }
})

BoatSearchResultsHelper.js
({
    onSearch : function(component, boatTypeId){
        var action = component.get( "c.getBoats" );
        var returnBoats;
        console.log("In helper of boat search results and value is ",boatTypeId);
        action.setParams({
            boatTypeId : boatTypeId
        });
        action.setCallback(this, function( response ){       
            //console.log(response.getReturnValue());
            returnBoats = response.getReturnValue()
            component.set("v.boats",returnBoats);
            //debugger;
            this.returnBoats = returnBoats;
            console.log("length is ",returnBoats.length);
        });
        $A.enqueueAction(action);
    }
})

returnBoats has value however, component.set("v.boats",returnBoats) statement is not setting any value to boats attribute as a result the aura component iteration is not executing tiles component.

Thanks,
Vinay
Dear folks,

How to find smallest number in array using Map

Example 1:

Input: nums = [2,5,6,9,10]

Explanation:
The smallest number in nums is 2.


Here is code tried using Maps but no success
public class GCDArray {
    public static List<String> greatestdiv(String input) {
        system.debug(input);
        List<String> inputList = input.split('');
        system.debug(inputList);
        Map<String,Integer> counts = new Map<String,Integer>();
        system.debug(counts);
        for(String s1:inputList) {
            counts.put(s1,0);
            system.debug(counts);
        }
        for(String s1:inputList) {
            counts.put(s1,counts.get(s1)+1);
        }
        system.debug(counts);
        String maxKey = counts.isEmpty()?null:new List<String>(counts.keyset())[0];
        system.debug(maxKey);
        for(String s1:counts.keySet()) {
            maxKey = counts.get(s1)>counts.get(maxKey)?s1:maxKey;
        }
        system.debug('The smallest number in array is'+ maxKey);
        system.debug(counts.get(maxKey));
        
        List<String> resultList = maxKey.split('');
        for( Integer S : counts.keySet() ){
            system.debug(S);
            resultList.add(S,counts.get(S));
            system.debug(resultList);
            
            
        }
        
        
        return resultList;      
    }
    
    
}

Regards,
Fiona
 

I have a screen flow that uses Eric Smith's datatable component. In this flow I have a quantity field that I want the user to enter a number (eg 1-100) but when you click (inline edit) to enter the value, the input field is enormous and it overlays the other fields. How can I reduce the size of this? I asked Eric and he said that his datatable flow component uses the Salesforce base datatable. He suggested that it's possible a CSS override could be used but SF has not published any details about the innards of this component. Does anyone have any ideas on how this could be achieved?

PS: The size of the quantity field as defined in the object and the width of the field in Eric's datatable component configuration have no impact on this, it's inherent in the underlying Salesforce datatable.

User-added image

I want to display the sample of the data present in visualforce component when the button is clicked.the button is created on a lightning component.any suggestions.
 
Hello Developers,

I have created Field dependencies, Status picklist field is controlling and sub status picklist field is dependent. I have a requirement of showing path of both Status and Sub status picklist fields on the record page. I did that by Aura component but dependent picklist(sub status) is showing all the values on the path.

On path dependent picklist(sub status) should only show the values related to what user selects in controlling field (Status) means dependent picklist path should change and only show values on behalf of what we select in the controlling field.

Here is what I implemented: -

<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" > <aura:attribute name="variant" type="String" default="non-linear"/> <aura:attribute name="hideUpdateButton" type="Boolean" default="true"/> <lightning:picklistPath aura:id="picklistPath" recordId="{!v.recordId}" variant="non-linear" picklistFieldApiName="Sub_Finance__c" onselect="{!c.handleSelect}"> </lightning:picklistPath> </aura:component>

({ handleSelect : function (component, event, helper) { var stepName = event.getParam("detail").value; var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": "Success!", "message": "Toast from " + stepName }); toastEvent.fire(); } }) 

Does anyone knows solution for this requirement?
Hi,
I have lightning components that displays images from ContentVersion as thumbnails and also links, when I click on the image its directly downloading the image but I would like it to open as preivew or open the image in a new tab/window. please advice.
below is the current line that displays image thumbnails with link to open big
<aura:iteration items="{!v.items}" var="content">
	       <a href="/sfc/servlet.shepherd/version/download/'+{!content.id}" target="_blank"> <img src="/sfc/servlet.shepherd/version/download/'+{!content.id}" width="100" height="100"/> </a>
	    </aura:iteration>

 
There is a weird scenario I'm facing while I try to bind the markup UI tags with lighting aura:attribute as type sObject (fields). I'm trying to bind data to sobject's fields for different lightning:input tags, For one sObject attribute the binding works perfect, but in the same way for another sObject the data is not getting bound. For Ex:
<aura:attribute name="student" type="JN_Student__c" access="global" default="{'sobjectType' : 'JN_Student__c'}" /> <lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name"value="{!v.student.JN_Last_Name__c}" maxlength="20" required="true"/>
above works perfectly and the data persists as I show/hide this section. WHEREAS for,

<aura:attribute name="insuranceInstance" type="JN_Insurance__c" access="global" default="{'sobjectType' : 'JN_Insurance__c'}" /> <lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name" value="{!v.insuranceInstance.Name}" maxlength="20" required="true"/>

the 'v.insuranceInstance.Name' doesn't persists its value.
Please reply if anyone knows/encounted the same.