• mukesh gupta
  • PRO
  • 4545 Points
  • Member since 2015
  • 9X Salesforce Certified

  • Chatter
    Feed
  • 133
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 122
    Questions
  • 1113
    Replies
I am trying to update the AnnualRevenue of Account into Opportunity amount and it is working for update.....During testing I am getting error System Variable does not exist: Amount
Here is the code
@isTest
public class OppAmountUpdate_Test {
    @isTest
    public static void myMethod_Test(){
        
        Account acc = new Account();
        //acc.Id = '0015j00000dkZj0AAE';
        acc.Name = 'Aviral Dandge';
        acc.AnnualRevenue = 25000;
        insert acc;
        
        Opportunity opp1 = new Opportunity();
        opp1.Name = 'Dandge Pvt Ltd';
        opp1.CloseDate = system.today();
        opp1.StageName = 'Qualification';
        insert opp1;
        
        Test.startTest();
        acc.AnnualRevenue = 50000;
        update acc;
        Test.stopTest();
        
        /*Opportunity oppNew = new Opportunity();
        oppNew.AccountId = acc.Id;*/
        /*Account newAcc = [Select Name, Id, AnnualRevenue from account where Id =: acc.Id];
        system.assertEquals(25000, acc.AnnualRevenue);*/
        
        List<Opportunity> opp = [Select AccountId, id, Amount from Opportunity 
                           where AccountId =:acc.Id];
        
        
        system.assertEquals(50000, opp.Amount);
        
            
        
        
    }

}
What modifications can I make in the code?
 
How to insert or copy custom object record data to account object automatically after custom object record gets approved

I have custom object student account and i want the functionality to copy some student object field record data to account object after student record get approved. there are about 10 fields record to copy in 1 time.
 
I have two objecs in salesforce that are beeing feed data from an external system. How do i check how data is being fed into those object. 
Whenever a contact is inserted, if that contact is associated with an account, then update that account name from this  newly inserting contact name. It has to be bulkified.  If the contact name is "John", then the associated account's name should also be "John:

public Contact trigger updateAccount (AFTER INSERT){

Map<Id, Account> accountList = New Map<Id, Account> ();


for(Contact con: Trigger.New){

   if(con.AccountId){

    Account acc = New Account();
    acc.Name = con.LastName;
    acc.Id = con.AccountId;
    accountList.put(acc.Id, acc);

   }
}
UPDATE accountList.values();
}

I would like to know why we would get an error if we use LIST in production and that we have to use either MAP or SET.
Hi everyone.
I can't create a contact. Please tell me what is wrong.

User-added image


My code:
Html:
<template>
    <lightning-card if:true={showModal}>
       <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <lightning-button-icon class="slds-modal__close" title="Close" icon-name="utility:close" icon-class="slds-button_icon-inverse" onclick={handleDialogClose}></lightning-button-icon>
                <div class="slds-modal__header">
                    <h1 id="modal-heading-01" class="slds-modal__title slds-hyphenate">Create contact with custom lookup</h1>
                </div>
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">                  
                   
                   
                   
                    <lightning-card title={cardTitle}>                    
                        <div class="slds-m-around_medium">
                            <lightning-record-edit-form
                         
                            object-api-name="Contact"
                        >
                            <lightning-messages> </lightning-messages>
                           
                            <lightning-input-field  field-name="LastName"></lightning-input-field>
                           
                            <lightning-button label="Save" onclick={handleClick}></lightning-button>
                        </lightning-record-edit-form>
                        </div>
                    </lightning-card>

                </div>    
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open" role="presentation"></div>
    </lightning-card>
</template>

Js:
import { LightningElement, api, wire, track } from 'lwc';
//import LNAME_FIELD from '@salesforce/schema/Contact.Name';
import LNAME_FIELD from '@salesforce/schema/Contact.LastName';
import insertContact from '@salesforce/apex/ContactTableProjectSecond.addContact';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import getContacts from '@salesforce/apex/ContactTableProjectSecond.getContacts';
import {refreshApex} from "@salesforce/apex";
export default class LwcNewContactUsingApexImperativecalling extends LightningElement {

    showModal = false;
 
    LastName = LNAME_FIELD;
    //object-api-name="{objectApiName}"
    //record-id="{recordId}"
    @api recordId;
    @api objectApiName;
 
    @wire(getContacts)
    wiredCallback(result) {
        this._wiredResult = result;
    }
    handlelnameChange(event) {
        this.LastName = event.target.value;
        window.console.log("LNAME", this.LastName);
    }
    handleClick(event) {
        console.log("handleClick", event);
        const contact = {
         
            LastName: this.LastName,
       
        }
        insertContact ({ con : contact })
            .then(() => {            
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Success',
                        message: 'Contact created',
                        variant: 'success',
                    }),
                );
                this.showModal = false;
                return refreshApex(this._wiredResult);
            })
            .catch((error) => {
                this.dispatchEvent(
                    new ShowToastEvent({
                        title: 'Error creating record',
                        message: error.body.message,
                        variant: 'error',
                    }),
                );
                console.log('error', JSON.stringify(error));
            });
    }
   

    @api show() {
        this.showModal = true;
    }
    handleDialogClose() {
        this.showModal = false;
    }  
    // @track selectedAccountId;
    // handleSelected(event){
    //     console.log(event.detail);
    //     this.selectedAccountId = event.detail;
    // }
}

Apex:
public with sharing class ContactTableProjectSecond {
    @AuraEnabled(cacheable=true)
    public static List<Contact> getContacts() {
        return [
            SELECT Id, FirstName, LastName, Phone, Email, Account.Name, AccountId, CreatedDate
            FROM Contact
        ];
    }
    
    @AuraEnabled(cacheable=true)
    public static List<Contact> searchContacts(String searchKey) {
        String searchKeyword = '%' + searchKey + '%';
        List<Contact> contacts = [
            SELECT Id, FirstName, LastName, Phone, Email, Account.Name, AccountId, CreatedDate
            FROM Contact
            WHERE Name LIKE :searchKeyword
        ];
        return contacts;        
    }

    @AuraEnabled
    public static void deleteContact(Id recordId) {   
        List<Contact> contact = [SELECT Id FROM Contact WHERE Id = :recordId];
        delete contact;   
   }
    
    @AuraEnabled
    public static Contact addContact(Contact con) {
        //Contact contact = new Contact(); 
        system.debug('con'+con);
    insert con;
        return con;
    } 
    
    @AuraEnabled(cacheable=true)
    public static List<account> getCustomLookupAccount(String actName) {
        List<account> accountLookupList =  new List<account>();
        System.debug('accountLookupList' + accountLookupList);
            if (actName != '') {
            String accountName = '%' + actName + '%';
            accountLookupList = [SELECT Id, Name FROM Account WHERE Name like:accountName];
            return accountLookupList;
            }
        return accountLookupList;
        }  
}
Hi, this method gives me a map. I would like to call this method in aura component and haveit displayed on the screen .

User-added image
I have an custom object called ProductDetail__c where i am trying to fetch the data from apex method using @wire as function as shown in the screenshot and after clicking view details button , i want to navigate to the record detail page but it is not happening.

Can someone help me with this please and how to put the debug statements inorder to debug on my own.

Sorry i am new to LWC.

Apex class
============================================
public with sharing class ProductManager {
    @AuraEnabled(cacheable=True)
    public static List<ProductDetail__c> fetchProductData(){
       
        List<ProductDetail__c> ProdList=new List<ProductDetail__c>();
        ProdList=[select Id,Name,Product_Family__c,Product_Description__c,Product_Code__c from
                    ProductDetail__c where IsActive__c = True];
        return ProdList;
    }
}
==========================================
import { LightningElement, wire } from 'lwc';
import  fetchProductData  from '@salesforce/apex/ProductManager.fetchProductData';
export default class ServerProductData extends LightningElement {
    ProductDetails;
    ProductId;
    errorDetails;
    @wire(fetchProductData)
    ProductDetailInfo({error,data})
    {
        if (data)
        {
            this.ProductDetails= data;
        }
       
        else if(error){
            this.errorDetails= error;
        }
    }
    navigateDetails(event){
        this.ProductId = event.target.value;
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attributes:{
                recordId:this.ProductId,
                objectApiName:'ProductDetail__c',
                actionName:'view'
            }
        });
    }
}
=================================================

<template>
    <div class="slds-box">
        <template if:true={ProductDetails}>
            <div class="slds-grid slds-wrap slds-gutters">
                <template for:each={ProductDetails} for:item="Prod">
                    <div class="slds-col slds-large-size_4-of-12 slds-medium-size_1-of-12 slds-size_1-of-12 slds-p-around_small" key={Prod.Id}>
                        <lightning-card title={Prod.Name}>
                            <lightning-button label="View Details" variant="success" slot="actions" onclick={navigateDetails} value={Prod.Id}>
                            </lightning-button>
                            <div class="slds-var-p-around_small">
                                <p>{Prod.Product_Description__c}</p>
                                <p>{Prod.Product_Code__c}</p>
                            </div>
                        </lightning-card>
                    </div>
                </template>
            </div>
        </template>
    </div>
</template>
=================================================
User-added image
First Name and last name fields are visible on edit page on user object, but the same is not visible under the fields and realtionship section of the user object, Can u some one help with the reason
Is there a way to create a report to show all active users with their profiles, roles, licenses and last login date? If so how can i create it.
  • April 13, 2022
  • Like
  • 0
hi how can i achieve this
//id
String a = '111,112,113,114 etc';

//my ouput should like this

String Result1 = 111,112,113
String Result2 = 113,114 etc

 
Hi I would like to know if it is possible to display in a function (yesBtn) a field of a sattata list in another function (getSelectedProd). I would like to display the Name__c of this list (prodList2). As you can see I did a test in the function "yesbtn "but it doesn't give me anything back
Controller:
getSelectedProd: function (component, event) {
                component.set("v.popup",true);
            var selectedRows = event.getParam('selectedRows');
            console.log('selRows -> ' + JSON.stringify(selectedRows));
            var selectedRowsIds = [];
            for(var i=0;i<selectedRows.length;i++){
                selectedRowsIds.push(selectedRows[i].Id);
                component.set("v.Name", selectedRows[i].Name__c);
            }     
            component.set( "v.prodList2", selectedRows );
            var count = component.get('v.Counter');
            count = count+1;
            
            var list = component.get("v.prodList2");
            component.set('v.Counter', list.length);
            if(list.length==0){
            component.set("v.control",false);
            }
            else{
            console.log("Size = "+list.length);
            }
            },
            handleClick : function (component, event, helper) {
            component.set( "v.control", true );
            
            },
            yesBtn : function(component,event,helper){
                    var quality=component.find("prova").get("v.value");
                    console.log("Quality "+ quality);
                    var name=component.get("v.Name");
                    console.log("Name book popup " + name);
                    var list=component.get("{!v.prodList2.Name__c}");
                    console.log("Name book list " + list);
                    var qu=component.get("v.prodList2").AvailableQuantity__c;
                    while(list==name){
                        var quantity = 0;
                        quantity=qu-quality;
                        console.log("differenza "+quantity);
                    }
                },

 
This is my method :
public static List<String> UpdateStatus(List<String> recordId ){
        //Fetch the current values in sub status multiselect picklist
        GPO_Rebate_Payment__c gpopayment = [SELECT Sub_Status__c,Status__c FROM GPO_Rebate_Payment__c where id IN :recordId LIMIT 1];
         List<String> currentStatusValues = gpopayment.Sub_Status__c.split(';');
        
        If(gpopayment.Status__c == 'Pharma Payment')
        {
            if(!currentStatusValues.Contains('Overdue'))
            {
                 currentStatusValues.add('Overdue');
            }
        }
        else{
            if(currentStatusValues.Contains('Overdue'))
            {     
                for(Integer i = currentStatusValues.size() - 1; i >= 0; i--) {
                if(currentStatusValues[i].equals('Overdue')) 
                {
                currentStatusValues.remove(i);
                }
    }
                 //currentStatusValues.('Overdue');
            }
        /* String newStatusValues;
        newStatusValues = string.join(currentStatusValues ,';');
         gpopayment.Sub_Status__c = newStatusValues;*/
    
    }
        return currentStatusValues;

}

i have written this test method but it is giving me error of illegal assignment from List to List:
@isTest
    public static void UpdateStatusTest(){
        GPO_Rebate_Payment__c gpopayment = new GPO_Rebate_Payment__c();
        gpopayment.name = 'test class';
        gpopayment.Status__c = 'Pharma Payment';
        gpopayment.Sub_Status__c = 'In Progress';
        
        update gpopayment;
        
        test.startTest();
        List<String> recid = [SELECT Id FROM GPO_Rebate_Payment__c WHERE name='test class'];
        GPORebatePaymentSubStatusUpdate.UpdateStatusTest(recid.Id);
        test.stopTest();

 

Hi there! 

I'm new at Salesforce and I'm trying to debug a class but I'm receiving this error "System.QueryException: unexpected token: 'LIMIT' at line 24, column 1. Can anyone advise what is wrong_ as I cannot seem to find the answer, thanks 

public with sharing class dvd_CustomLookupController {

    @AuraEnabled(cacheable=true)
    public static List<sObject> search(String searchTerm, String searchField, string myObject, String filter) {
        
        String myQuery = null;
        String searchFieldWhere;
        system.debug(searchTerm+':'+searchField+':'+myObject+':'+filter);
        if(String.isBlank(searchField)){
            searchField = ' ';
            searchFieldWhere = 'Name';
        }else{
            searchFieldWhere = searchField;
            searchField = ' ,' + searchField;
        }
        if(String.isNotBlank(filter)){
            myQuery = 'Select Id, Name '+searchField+' from '+myObject+' Where '+searchFieldWhere+' Like  \'%' + searchTerm + '%\' AND '+filter+' LIMIT  5';
        }else {
            if(String.isBlank(searchTerm)){
                myQuery = 'Select Id, Name '+searchField+' from '+myObject+' Where LastViewedDate != NULL ORDER BY LastViewedDate DESC LIMIT  5';
                
            }else {
                myQuery = 'Select Id, Name '+searchField+' from '+myObject+' Where '+searchFieldWhere+' Like \'%' + searchTerm + 'DESC LIMIT  5';
            }
        }
        List<sObject> lookUpList = database.query(myQuery);
        system.debug(myQuery);
        
        system.debug(lookUpList.size());
        return lookUpList;
    }
}

hi, I'm creating a lightning application the purpose is to show all the Books in a component with the intent of selecting a book and to create a purchase proposal. after having created a component which shows me the cards of the books, selecting a book should redirect me to another component that acts as a cart to continue my 'order'. How can you connect a component that at the click of a button redirects me to another component where it shows me the cart page on the screen?
Hi everyone! :) 

Today I want to ask simple question - how to change columns in AddProduct list on Quote? :) 

I want to hide the Product Details column in this list. :) 

User-added image
Hi Team,
In debug i found it's inserting duplicate values how to avoid duplicate values using apex class.

Error:

Before Insert or Upsert list must not have two identically equal elements

Thanks
KMK
  • March 22, 2022
  • Like
  • 0
Hi All,

I need to update row item value on change event
 
<template for:each={selectedOlis} for:item="oli" for:index="index">
    <div key={oli.Id}>
        {oli.Name} &nbsp; {index}
        <lightning-input type= "string" data-index={index} label="Address" value={oli.address}
            placeholder="Quantity" onchange={handleListInputChange}>
        </lightning-input>
        
    </div>
	</template>

JS:-

handleListInputChange(event){
//wheen user type then  update value={oli.address}
}

Please suggest
Hi Expert,

I am using Lightning-data-table with rowaction (VIEW, EDIT, DELETE).
but dropdown list cut off. not visible all options, i know solution if height added in  class 
.slds-scrollable_y, 
but not able to set height in this class

User-added image

Can you please assist






How can set 

this LWC Quickaction component
Hi All,

I am using Lightning-data-table with rowaction (VIEW, EDIT, DELETE).
but dropdown list cut off. not visible all options

this LWC Quickaction component
User-added image

Please suggest.
Hi All,

I need to update Custom label from LWC. my Custom label is Hello {0} and {1}.

How to update by LWC,


Thanks
Hi Team,

I want to hide Liightning componet Close Button(Top right corner) or cross button.User-added image 
when i click on quick action then one of lightning component assosciated with it and open, but need to remove close button.

Please suggest

 
I am using a process buider:- 

if user cloned any opportunity then one of my process builder should not execute, after creation of this opportunity if user edit this opportunity then process builder should execute.

Please suggest
Hi Expert,

I have a custom field on Task object, and now i want to update task by API. i have tried to update by Postman, but facing error.
 
{
        "message": "insufficient access rights on object id",
        "errorCode": "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY",
        "fields": []
    }

 Please suggest

Regards
Mukesh
Hi Expert,

I am using add error method, when criteria match then addError method call, but here script doenot stop and execute next loop.

i want to stop script when addError call. i have used break; return; but nothing happen

 
for (Opportunity currOpp: newOpportunities_1){
              System.debug('currOpp name '+currOpp.name);
            if (currOpp.RecordTypeId!=PMRecordTypeId.Id  ){
                currOpp.addError(Label.pmr);   
               
            }
          }

for (Opportunity currOpp: newOpportunities_2){
              System.debug('currOpp name '+currOpp.name);
         
          }

Thanks 
Mukesh

 
Hi Expert ,

I am creating dynamic check boxes that's crated perfect, change event is not working for created check boxes;

when i select any check box then get error
getting error :- Unable to find action 'handleSelectedOLI' on the controller 
 
for(var i = 0; i<5; i++){
 $A.createComponent(
            "ui:inputCheckbox",
            {
                "aura:id": "checkBoxOLI",
                "value":chekboxVal,
                "change": component.getReference("c.handleSelectedOLI")
            },
            function(newButton, status, errorMessage){
                //Add the new button to the body array
                if (status === "SUCCESS") {
                    var body = component.get("v.body");
                    //body.push(newButton);
                    component.set("v.body", newButton);
                }
                else if (status === "INCOMPLETE") {
                    console.log("No response from server or client is offline.")
                    // Show offline error
                }
                else if (status === "ERROR") {
                    console.log("Error: " + errorMessage);
                    // Show error message
                }
            }
        );  
		
handleSelectedOLI: function(component, event, helper) {
        alert('change ecevt ');
    
    },

Please suggest

Regards
Mukesh
Hi Expert,

I want to destroy selected check box when user try to select all and click on delete buttion.
 without destroy this is exist already and make extra check boxes that's was previously deleted so now i want to destroy selected items

Below code is creating check boxes:-

this is select All check box
<ui:inputCheckbox value = "{!v.isSelectAll}" change="{!c.handleSelectAllOLI}" aura:id="selectAll"/>

this is list of check boxes:-
<aura:iteration items="{!v.DEFProductInstance}" var="item" indexVar = "indx">
<ui:inputCheckbox aura:id="checkBox" />
 </aura:iteration>


Please suggest

Thanks
When manager reject opportunity then error message display from trigger, but i want to bypass addError message in apex trigger. for spicific condition user face addError message, but when opportuntiy reject by manager then i want to by pass this error message.

Please suggest

Regards
Mukesh 
Hi Expert,

I am using below code but not able to get maximum length  on keyUp event.

 
<ui:inputCurrency class="slds-input" aura:id="curr" format="##,##,###,##0.00" maxlength="6" updateOn="keyup" keyup = "{!c.changesValueInput}"/>

Please suggest
 
Hi Expert,

I am creating contact by 'e.force:createRecord', but now i want to created contact record Id. after this event. 

Can you please suggest.

Regards
Mukesh 
Hi Expert,

I am trying to create a lwc project in VS code, but when i try to create 
then facing error:

command 'sfdx.force.project.create' not foundUser-added imagePlease suggest.

I am using jdk1.8.0_231 for 64 bit
Hi expert,

I have multiple country picklist in lightning compont that's is iterating in Table TR
we i choose any picklist value 'UAS' and click on save button than this picklist should be disable.

but when i change of picklist then picklist disable on selection time. but i want to disable on save button.

Please suggest
<aura:iteration items="{!v.CountryDetails}" var="item" >
<tr> 
<td class="slds-cell-wrap">
                        <lightning:select name="statusFld" label="" value="{!item.Country__c}" disabled="{!item.Country__c == 'Closed Won')}">
                            <option value="--None--">--None--</option>
                            <aura:iteration items="{!v.listCountry}" var="val">
                                <option value="{!val.value}" selected="{!val.value==item.Country__c}">{!val.key}</option>
                            </aura:iteration>
                        </lightning:select>
                    </td>
</tr>
</aura:iteration>

 
Hi I am using visualforce page to open Lightninng component in new tab:-

on opportunity object -->> button & Link (Name:-AddProduct)

add URL parameter :- 

/apex/OppProduct_VFP?oppId={!Opportunity.Id}

when user click on 'AddProduct' button then below VF page open in new tab with lightnig component:-

OppProduct_VFP:-
<apex:page controller="TestController" tabStyle="Opportunity" lightningStylesheets="true">
    <apex:includeLightning />
    <div class="slds" style="margin-top:10px;margin-left:10px;"> 
        <div id="lightning" />
    </div>
   
    <script>
    

        $Lightning.use("c:AddProductApp", function() {
            $Lightning.createComponent(
                "c:AddProduct",
                {recordId : "{!OpportunityId}"},
                "lightning",
                function(cmp) {
                   
            });
        });
    </script>
</apex:page>

i have a close button in AddProductController to close this tab but not able to closed this tab getting UNDEFINED in console log. i am not able to get TabId by this code.

 
Close : function(component, event, helper){
        var workspaceAPI = component.find("workspace"); // mentioned in component 
          workspaceAPI.isConsoleNavigation().then(function(consoleResponse) {  
              console.log('consoleResponse-->>> '+consoleResponse) // return undefined
              workspaceAPI.getFocusedTabInfo().then(function(tabResponse) {
                  console.log('tabResponse-->> '+tabResponse)// return undefined
                   var isSubtab = tabResponse.isSubtab;
                  console.log('isSubtab-->> '+isSubtab);// return undefined
              });
        });
Please suggest and let me know where i am wrong
​​​​​​​
I am using a lightning componet, whrn i click on a button then this coponent open. on this component i have a close button. when i click on this closed button page redirect to previous page, but tab not closed.

i am using below code for tab close
closeFocusedTab : function(component, event, helper) {
         var workspaceAPI = component.find("workspace");
        //alert(workspaceAPI);
        workspaceAPI.getFocusedTabInfo().then(function(response) {
            //alert('aaaa -- '+response);
            var focusedTabId = response.tabId;
            workspaceAPI.closeTab({tabId: focusedTabId});
        })
        .catch(function(error) {
            console.log(error);
        });

    
    }

    Can you please suggest.

User-added image
Hi Expert,

I want to add attachment on record creation time in apex code, but in attachment custom code  we need record Id, but record is not created. so how achive this functionality,

Example: when we fill any exam from then we can attachemtn or document, and then save the record.

Thanks
 
Hi Expert,

i want to open a popup box that should be open when user logged In. when user  closed this then this will not reopen for this session. if user logged in again then popup should be open .

what i have done:

create a lightning component and added this on home page layout. but this popup open again and again when home page refresh. 

So can you please suggest what should i use sothat model popup should open once for current session.

Regards
Mukesh
Hi Expert,

I want to use Remote Objects in lightning component , below code is working in visualforce  pages, but now i need to implement this code in lightning component.

for example:- 
  <!-- Remote Objects definition to set accessible sObjects and fields -->
    <apex:remoteObjects >
        <apex:remoteObjectModel name="Warehouse__c" jsShorthand="Warehouse" 
            fields="Name,Id">
            <apex:remoteObjectField name="Phone__c" jsShorthand="Phone"/>
        </apex:remoteObjectModel>
    </apex:remoteObjects>

Thanks
Mukesh
Hi Expert,

I want to create some demo on marketing cloud  journey builder. Can any one share about how to acces journey builder in markeing cloud.

Thanks
Mukesh
Hi Expert,

I need to create an application for me to send SMS directly from Salesforce. Please suggest.

User-added image
Hi Expert,

I am using a test class for coverage 75% code, but few things are not covered. Can any one suggest what is going wrong.

this my test Class: --
@isTest
public class TestProfessorSelectCourse {
    @isTest static void ProfessorCourse(){
       
        
        Professor__c prof = new Professor__c(Name ='JP',Email__c='jp@gmail.com');
        insert prof;
        
        Class__c cls = new Class__c(name='12G', Class_Teacher__c = prof.id);
        insert cls;
        
        Course__c cors = new Course__c(Professor__c=prof.id,Class__c =cls.id, name='Ruby', Start_Date__c= Date.today() , End_date__c= Date.newInstance(2017,03,20));
       	//Professor__c prof = new Professor__c(Name ='JP');
        //cors.Professor__c = prof.Name;
        insert cors;
    }
}

and below is my main class


User-added image

Thanks 
Mukesh
Hi experts,i have created a Debug log for the user and then i run the testclass unable to see the debuglogs please help me out

Thanks in advance.
In Child object - Formula field- Need to check Parent object - Picklist field Starts with 'B' - Then A field value should be updated.

If picklist field  starts with 'C'- Then B field valuse should be updated  else - Empty should be updated. Its possible in Formula field?
Hi Guys, in want to create a Validation Rule on PR or PRLI that check when the Status of the PR is changed to "send" it will works only when a PRLI (Product) ist added. So the User can not send a PR without any Items.

Anybody has a Tipp?
Thx.
 
Hi Everyone! :) 

Email-to-case doesn't work with Lightning Email Templates. I am using Flow and Email Alerts to send the emails to customers. Under Email tab on Case I can see only emails with Classic Template. The same situation with response from customer's email box. I can see only responses for Classic Templates, but not for Lightning.

Do you have any idea? :) 
Created this Apex class
public class DuplicateLeadMergeHandler 
{    
    public static void MergeLead(List<Lead> newLead)
    {
        Set<String> emails = new Set<String>();
        Set<String> phones = new Set<String>();
        Map<String, Lead> masters = new Map<String, Lead>();
        
        for(Lead ld : newLead)
        {
            emails.add(ld.Email);
            phones.add(ld.Phone);
        }
        
        emails.remove(null);
        phones.remove(null);
        
        for(Lead ld: [SELECT Id,Email,Phone FROM Lead WHERE (Email = :emails OR Phone = :phones) AND Id NOT IN :newLead AND IsConverted = false])
        {
            If(ld.Email != Null)
                masters.put(ld.Email, ld);
            
            else 
                If(ld.Phone != Null)
                masters.put(ld.Phone, ld);
        }
        for(Lead ld : newLead)
        {
            Lead master = new Lead();
            If(masters != Null && masters.size() > 0 && masters.containskey(ld.Email))
            {
                master = masters.get(ld.Email);
            }
            Else   
                If(masters != Null && masters.size() > 0 && masters.containskey(ld.Phone))
            {
                master = masters.get(ld.Phone);
            }

            If(master != null)    
            {     
                merge master ld;
            }
        }
    }  
}
but its showing an errorLead errorplease help me solve this problem

Thanks & Regards 
SFDC Strange
 
@isTest private static void test_send() {
        
        Account countryTeam = AIM_TestDataUtility.accCountryTeamRecord('AIM_Notification_Mailer_Test');
        insert countryTeam;
        Test.startTest();
        List<AccountTeamMember> countryTeamMembers = AIM_TestDataUtility.accCountryTeamMembers(countryTeam.Id);
        insert countryTeamMembers;
        EmailTemplate template = [SELECT Id, DeveloperName FROM EmailTemplate WHERE IsActive = true LIMIT 1];
        Test.stopTest();
Hi All, 

Opportunity has extra dots on the product name, Can someone tell me why it is showing dots below name which is standard functionality and it is happening for few products only.

User-added image

Thanks,
T N Lakshman
Hi all

I have this following method which is sending email.It was working fine till yesterday. I just changed the message in email template today .when i try to test it showing STORAGE_LIMIT_EXCEEDED exception. I tried with different emails also. It is not working. Can anybody give solution to this.

private void sendEmail(){
        String EmailBody,Subject;
        Contact prjLead;
        String prjLeadEmail;
        List<EmailTemplate> emailTemplateIds = new List<EmailTemplate>();
      
         //Fetch Email Template Id to be send to Candidate and Project Lead 
         
         If(removeProjInterest = True) 
             emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Request_To_Leave_Project' LIMIT 1] ;
                                                
                                                 
         else                                                   
              emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Project_Join_Request' LIMIT 1];                                     
        
        //Fetch the Project Lead Details
        If(selPrjLeadId != null){
             prjLead = [SELECT Id,FirstName,Name,Email 
                                         FROM Contact 
                                         WHERE id=:selPrjLeadId 
                                         LIMIT 1];
             projectLead = prjLead.Name; // Value referred in VF Page
             prjLeadEmail = prjLead.Email;
             prjLeadOrManager = 'project lead';  //Value referred in VF Page
        } else{
            //If Project Lead not defined, Email fetched from Custom Metadata settings
            MR_Project_List_Setting__mdt PrjListMetaData = [SELECT PMO_Email__c,PMO_Name__c 
                                                                  FROM MR_Project_List_Setting__mdt
                                                                  WHERE DeveloperName  ='PMO_Details' LIMIT 1];
            projectLead = PrjListMetaData.PMO_Name__c;
            prjLeadEmail = PrjListMetaData.PMO_Email__c;
            prjLeadOrManager = 'project manager';      //Value referred in VF Page
        }
        
        //New instance of a single email message sent to candidate
       Messaging.SingleEmailMessage emailCand = new Messaging.SingleEmailMessage();
       List<String> canEmailList = new List<String>();
       List<String> prjLeadEmailList = new List<String>();
        
        //Fetch the Candidate details
       If(contactId != null){
             
              EmailBody = emailTemplateIds.get(0).Body;
           If(EmailBody !=null){
               EmailBody = EmailBody.replace('Candidate',candFirstName);
               EmailBody = EmailBody.replace('project', selPrjName);                        
               EmailBody = EmailBody.replace('lead',projectLead);
               EmailBody = EmailBody.replace('plOrpm', prjLeadOrManager); 
               EmailBody = EmailBody.replace('LeadEmail',prjLeadEmail);  
               if(removeProjInterest = True) 
               {
               EmailBody = EmailBody.replace('CandEmail',candEmail);
               }
            
           }
              canEmailList.add(candEmail);
              emailCand.toaddresses =canEmailList;
              prjLeadEmailList.add(prjLeadEmail);
              emailCand.ccaddresses = prjLeadEmailList;
              emailCand.setTargetObjectId(contactId);
               Subject = emailTemplateIds[0].Subject;
               emailCand.setSubject(Subject); 
                emailCand.setPlainTextBody(EmailBody);
              try{            
                  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailCand });
                  system.debug('Candidate & Project Lead Email Sent Successfully');
              }  catch(exception e){
                      system.debug('Error email');
                      apexpages.addmessage(new apexpages.message(apexpages.severity.error,e.getMessage()));
                      system.debug('Error Sending Candidate and Project Lead email '+e.getMessage());
               }
        
        }
            
 }
    

15:48:46.0 (588298556)|EXCEPTION_THROWN|[338]|System.EmailException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (588751848)|HEAP_ALLOCATE|[338]|Bytes:111 15:48:46.0 (588837018)|VARIABLE_SCOPE_BEGIN|[340]|e|Exception|true|false 15:48:46.0 (588947495)|VARIABLE_ASSIGNMENT|[340]|e|"common.apex.methods.MessagingStaticMethods$EmailExecutionException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []"|0xf2b3972 15:48:46.0 (588958756)|STATEMENT_EXECUTE|[340] 15:48:46.0 (588961850)|STATEMENT_EXECUTE|[341] 15:48:46.0 (588991982)|HEAP_ALLOCATE|[341]|Bytes:11 15:48:46.0 (589045155)|USER_DEBUG|[341]|DEBUG|Error email 15:48:46.0 (589057755)|STATEMENT_EXECUTE|[342] 15:48:46.0 (589254533)|HEAP_ALLOCATE|[342]|Bytes:107 15:48:46.0 (589428174)|VF_PAGE_MESSAGE|SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589439526)|STATEMENT_EXECUTE|[343] 15:48:46.0 (589451863)|HEAP_ALLOCATE|[343]|Bytes:47 15:48:46.0 (589472850)|HEAP_ALLOCATE|[343]|Bytes:107 15:48:46.0 (589489892)|HEAP_ALLOCATE|[343]|Bytes:154 15:48:46.0 (589502124)|USER_DEBUG|[343]|DEBUG|Error Sending Candidate and Project Lead email SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589525677)|METHOD_EXIT|[694]|01p3u00000ILbF5|ProjectsList.sendEmail()
I cannot read value using document.getelementbyId , it gives me an error AddNote:44 Uncaught TypeError: Cannot read properties of null (reading 'value')

Here is my Code : 

<apex:page standardController="Opportunity" lightningStylesheets="true" extensions="AddNoteController">
    
    
    <script type="text/javascript">
        function CheckUrl() {
            console.log('I AM IN ');
            
            var text = document.getElementById("{!$Component.div1.theform.thePageBlock.thePageBlockitem.test}").value;
            
            if(new RegExp("([a-zA-Z0-9]+://)?([a-zA-Z0-9_]+:[a-zA-Z0-9_]+@)?([a-zA-Z0-9.-]+\\.[A-Za-z]{2,4})(:[0-9]+)?(/.*)?").test(string1)) {
                alert("Url is present in this statement");
                 console.log('I AM IN IF OF THE CALL');
            }
            else {
                console.log('I AM IN ELSE OF THE CALL');
                savenote1();
                
            }
        }
    </script>
    
    <div class="slds-scope" id="div1">
        
        <apex:form  id="theform">
            <apex:pageBlock >
                <apex:pageBlockSection  id="thePageBlock">
                    <apex:pageBlockSectionItem id="thePageBlockitem" >
                        <apex:inputTextarea id="test" value="{!notes}" style="height:150px; width:200px"/>
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:commandButton value="Save" onclick="CheckUrl();return false;"/> 
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </apex:pageBlock>
            
            <apex:actionFunction id="savenote" name="savenote1" action="{!saveNote}"></apex:actionFunction>
        </apex:form>
        
    </div>
    
</apex:page>
hi, how to enable input calendar field for picklist option1-Reengagement
and disable the same input calendar field for picklist option 2-Inadeqautedata  in aura.

<lightning:select aura:id="industryPicklist" value="{!v.lead.Industry}" onchange="{!c.handleOnChange}" name="industryPicklist" label="Industry" required="true">
                    <option value="">--None--</option>
                    <option value="1">Re engagement</option>
                   
                    <option value="2">Inadequate Data</option>
                   <lightning:input type="date" name="input1" label="Re engagement" /> 
Thanks in advance
Hi! newbie here ..

I am trying to create a Visualforce Registration Page . But Iam getting Error: RegistrationPage line 8, column 9: The value of attribute "value" associated with an element type "apex:inputText" must not contain the '<' character. 

I created a registration sObject with all fields in VF page . When the Submit button is clicked , the registration information should be saved to the Registration sObject.

VF Page
<apex:page Controller="NewRegistration">  sidebar="false"   showHeader= "false"
<apex:form >
<apex:pageBlock id="pg1" >
  <apex:pageMessages  />
    <apex:pageBlockSection  columns="1">
     <apex:repeat> var=Re value="{!reg}"   </apex:repeat>
        <apex:inputText label="Name" value="{!re.name"}/>
       < apex:inputText label="Username" value="{!re.username__c}" />
        <apex:inputText label="Password" value="{!re.password__c}"/>
        <apex:inputText label="Confirm Password" value="{!re.confirm_password__c}"/>
        <apex:inputText label="Security Question" value="{!re.security_question__c}"/>
        <apex:inputText label="Security Answer" value="{!re.security_answer__c}"/>       
    </apex:pageBlockSection>
    <apex:pageBlockButtons>       
          <apex:commandButton value="Submit" action="!saveAction" reRender="pg1" />
    </apex:pageBlockButtons>
    
</apex:pageBlock>
</apex:form>
</apex:page>
</apex:page>




Controller Class
public class NewRegistration {

  Public Registration__c  reg {get ; set;}
 
  public NewRegistration(){
         reg = new Registration__c ();
     }    
     
    public void saveAction(){
      system.debug ('saveAction inside' +reg);  
       
        insert reg;
        if (reg.name !=null) {        
        Apexpages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO,'Registration Saved Successfully'));
     }
     
}
}






 
Hi!
I can’t find simple Inline edit custom table example like this:


User-added image

I have find desired example with datatable https://www.w3web.net/record-save-edit-field-inline-in-lwc/ (https://www.w3web.net/record-save-edit-field-inline-in-lwc/" style="color:#0563c1; text-decoration:underline) and with aura https://sfdcmonkey.com/2017/12/08/lightning-data-table-inline-editing/. I need same but with custom table, not with datatable, not with aura. I was given a link to a Inline edit snippet https://www.salesforcebolt.com/2021/09/ep-35-custom-inline-editing.html (https://www.salesforcebolt.com/2021/09/ep-35-custom-inline-editing.html" style="color:#0563c1; text-decoration:underline" target="_blank). But I can’t to interpose this fragment that the full table turned out. Please, tell me where can I find such an example?
My attempt:

Html
<template>
    <lightning-card title="Account" >
        <table border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse;" class="tblColPad">
            
            <tr>
                <th>Name</th>
                <th>Rating</th>
                <th>Dalete</th>
            </tr>

            <template for:each={getAccount.data} for:item="accountItem">
                <tr key={accountItem.Id}>
                    <td>
           <template if:false={editName}>
                            <span style="border-bottom: 1px dotted black"
                              >{accountItem.Name}
                              <lightning-button-icon
                                class="slds-float_right"
                                icon-name="utility:edit"
                                alternative-text="Update Name"
                                title="Update Name"
                                variant="bare"
                                size="medium"
                                onclick={handleNameEdit}
                              ></lightning-button-icon>
                            </span>
                          </template>

                          <template if:true={editName}>
                            <lightning-input
                              name="accountItem.Id"
                              value={accountItem.Name}
                              label=""
                              onchange={handleNameChange}
                            ></lightning-input>
                            <lightning-button-icon
                              class="slds-float_right"
                              icon-name="utility:save"
                              alternative-text="Update Name"
                              title="Update Name"
                              variant="bare"
                              size="large"
                              onclick={handleUpdateName}
                            ></lightning-button-icon>
                          </template>

         </td>
                    <td>{accountItem.Rating}</td>
                    <td><lightning-button label="Delete" size="small" variant="neutral" 
                    onclick={handleDelete} value={accountItem.Id} 
                    icon-name="utility:delete" icon-position="right" 
                    class="deleteButton"></lightning-button></td>
                </tr>
            </template>

        </table>
    </lightning-card>
</template>

Js
import { LightningElement, track, wire } from 'lwc';
import getAccounts from '@salesforce/apex/ProjectFour.getAccounts';
import {deleteRecord} from 'lightning/uiRecordApi';
import {refreshApex} from '@salesforce/apex';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
 
export default class ProjectFourCustom extends LightningElement {
    
  @wire (getAccounts) getAccount;
  @track recordId;
 
@track account;
  @track accountId;
  @track accountName;
  @track accountItem
  @track error;
  @track editName = false;

//   connectedCallback() {
//     getAccounts()
//       .then((result) => {
//         this.accountId = result.Id;
//         this.accountName = result.Name;
//       })
//       .catch((error) => {
//         this.error = error;
//       });
//   }

handleNameEdit(event) {
   console.log('handleNameEdit', event);
   this.editName = true;
 }

 handleNameChange(event) {
   console.log('handleNameChange', event);
   this.accountItem = event.target.value;
 }

 handleUpdateName(event) {
   console.log('handleUpdateName', event);
   const fields = {};
   fields[ID_FIELD.fieldApiName] = this.accountId;
   fields[NAME_FIELD.fieldApiName] = this.accountItem;

   const recordInput = { fields };

   updateRecord(recordInput)
     .then(() => {
       console.log('Done', event);
       this.editName = false;
     })
     .catch((error) => {
       console.log("Error updating date => " + error.body.message);
     });
 }


  handleDelete(event){
     this.recordId = event.target.value;
     deleteRecord(this.recordId) 
     .then(() =>{
 
        return refreshApex(this.getAccount);
        
     })
     .catch(error =>{
         window.console.log('Unable to delete record due to ' + error.body.message);
     });
  }
  
}

 
We have a before delete trigger on the account to prevent account deletion for all. So how can we make an exception for just one or two users?


trigger preventAccountDeletion on Account (before delete) {

    for(Account acc : trigger.old){
       
        acc.adderror('Account Cannot be deleted');
    }

}
I need to run a query but do not must return account id duplicated.

I followed these articles:
  • https://developer.salesforce.com/forums/?id=906F00000008yzrIAA
  • https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_groupby.htm
and this is my query: 
SELECT Id, AccountId FROM Asset GROUP BY AccountId

but this gives an error: 
[MALFORMED_QUERY] Field must be grouped or aggregated: Id

what do I need to change in my query to she works?
"This package can’t be installed. There are problems that prevent this package from being installed. Duplicate Name The name "Property__c" is already used on component type: Custom Object Definition. Please rename existing component."
Hi everyone,
I am getting error "Method does not exist or incorrect signature: void method3(List<opportunity>) from the type SampleTriggerHandler" on SampleTrigger class.

Please help me to fix this error.

Thanks in advance!
 
Trigger Code:

trigger SampleTrigger on Abc (before insert,before update, after undelete, after insert, after update) {
    
    if( trigger.isInsert && trigger.isBefore) 
    {
		SampleTriggerHandler.method1(trigger.new,Trigger.oldMap);
    }
    if( (trigger.isUpdate && trigger.isBefore) ||  (trigger.isundelete))
    {
        
        SampleTriggerHandler.method1(trigger.new,Trigger.oldMap);
    }
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)) 
	{
        SampleTriggerHandler.method2(Trigger.new, Trigger.oldMap);
    }
    
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate ))
    {
		SampleTriggerHandler.method3(trigger.new);
    }
    
}
 
TriggerHandler Code:


public class SampleTriggerHandler {

public static void method1
{
//code block
}

public static void method2
{
//code block
}

    
public static void method3 (List<opportunity> opp)
{
set<id> oppid = new set<id>();

List<opportunity> oppList = [select id, opp_name, from Opportunity where id=:oppid];

List<opportunity> updateList = new List<opportunity>();

Map<Id, opportunity> oppMap= new Map<id,opportunity>();

for(opportunity opp1: oppList) {

}
}
}

 

Beating my head against the wall and hoping someone can point out what I'm missing. I have a basic Lightning component with a drop-down. When that drop-down changes, I'd like the controller to make a second field visible through an aura if. But I can't even get the selection onchange to trigger. 

 

Component is basically:

<aura:attribute name="rType" type="string"/>  
<lightning:select name="rType" label="Record Type" value="{!v.rType}" required="true" onchange="{!c.syncSelection}">

With controller:

syncSelection: function (component, event, helper) {
        console.log("this worked");

 

I am trying to built a VF page. I wrote tags for labels and their input box but i was able to create only Labels not along with their Input Box. here is my VF Tags

<apex:page standardController="contact">
 <apex:form>
    <apex:sectionHeader title="Contact" subtitle="New Contact"/>
    <p> Contacts not associated with accounts are private and cannot be viewed by other  users or included in reports.</p>
    <apex:pageblock title="Contact Edit" Tabstyle="Contact">
   <apex:pageblocksection title="Contact Information"     columns="1" Collapsible="True">
    
       <apex:pageBlockSectionItem>
        <apex:outputLabel value="First Name"/>
        <apex.inputText value="{!Contact.FirstName}"/>
      </apex:pageBlockSectionItem>
       
       <apex:pageBlockSectionItem>
       <apex:outputlabel value="Last Name"/>
       <apex.inputText value="{!Contact.LastName}"/>
    </apex:pageBlockSectionItem>
       
        <apex:pageBlockSectionItem>
            <apex:outputlabel value="BirthDate"/>
            <apex.inputText value="{Contact.birthdate}"/>
    </apex:pageBlockSectionItem>
    </apex:pageblocksection>
                                                                       
    </apex:pageblock>
    </apex:form>
</apex:page>