• veer soni
  • SMARTIE
  • 724 Points
  • Member since 2020
  • Developer
  • ACS


  • Chatter
    Feed
  • 23
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 122
    Replies
Hi
Help please, I made the following trigger on Opportunity, where to being in a specific stage, create a record of a random user of a specific profile in the Opportunity Team
This is my trigger
trigger SLInsertOppTeam on Opportunity (before insert, before update) {
	for(Opportunity opp : trigger.New){	
		if(opp.StageName == 'A' && opp.is_new__c == false)
		{
            List<OpportunityTeamMember> member = [SELECT TeamMemberRole FROM OpportunityTeamMember 
                                                  Where OpportunityId = : opp.Id
                                                 AND TeamMemberRole = : 'Analist'];
            if(member.size() == 0 )
            {
				OpportunityTeamMember OTM = new OpportunityTeamMember();
            	OTM.OpportunityId = opp.Id;
				OTM.TeamMemberRole = 'Analist';
				OTM.OpportunityAccessLevel = 'Edit';       
            	List<User> uList = [SELECT Id FROM User Where IsActive = true and ProfileId = '00e4x000000NCX0AAO'];
            	if(uList.size() > 0){
                	Integer Ran = (integer)(Math.random() * (uList.size()));
            		OTM.UserId = uList[Ran].id;
            	}
            	insert OTM; 
             }   
		}   
    }  
}
When doing the trigger test, there is no error and it completes it well, but in the coverage it stays at 0%, could you help me to know what is wrong in the test or know how I can improve it so that it gives me a percentage of coverage feasible for you to take it as good
This is my Test
@isTest
private class SLTestInsertOMT {
    @isTest(SeeAllData=true)
    static void TestInsert() 
    {
        Test.startTest();
        Opportunity opp = [select Id, StageName, is_new__c from Opportunity where id_sf__c = '21022600147' LIMIT 1];
        if(opp.StageName == 'A' && opp.is_new__c == false)
        {
        	OpportunityTeamMember otm = new OpportunityTeamMember (OpportunityId= opp.Id, 
                                                             TeamMemberRole = 'Analist',
                                                             OpportunityAccessLevel = 'Edit',
                                                             UserId ='0054x000004Hu2xAAC');
        	insert otm;
        }
        System.assert(true); 
        Test.stopTest();
    }
}


 
Can someone help me with this problem? When I load the component tab then it shows 2 errors: isVpbank is not defined and isHsbcBank is not defined

creditCard.html
<template>
    <template if:true={isVpbank}>
        <img class="image-card" src={vpbankImage}/>
    </template>

    <template if:true={isHsbcBank}>
        <img class="image-card" src={hsbcImage}/>
    </template>
    
    
    <div class="slds-m-around_medium">
        <template if:true={creditCard.data}>
            <template for:each={creditCard.data} for:item="cc">
                <p key={cc.Id}>{cc.Name}</p>
            </template>
        </template>
    </div>

</template>

creditCard.js
import { LightningElement, api, wire } from 'lwc';

import myResource from '@salesforce/resourceUrl/creditCard';
import getCreditCard from '@salesforce/apex/CreditCardController.getCreditCard';
import isVpBankCredit from '@salesforce/apex/CreditCardController.isVpBankCredit';
import isHsbcCredit from '@salesforce/apex/CreditCardController.isHsbcCredit';


const VP_BANK = myResource + '/credit-card-images/vp-bank.jpg';
const HSBC = myResource + '/credit-card-images/hsbc.jpg';

export default class CreditCard extends LightningElement {
    vpbankImage = VP_BANK;
    hsbcImage = HSBC;
    isVpbank = false;
    isHsbcBank = false;
    
    @wire(getCreditCard) creditCard;

    connectedCallback() {
        isVpBankCredit().then((result) => {
            this.isVpbank = result;
            console.log(isVpbank);
        });

        isHsbcCredit().then((result) => {
            this.isHsbcBank = result;
            console.log(isHsbcBank);
        });
    }
}

​​​​​​​
Hello All,
I am new to development. I have written a trigger to add a newly created product into the standard price book. But while deployment to PROD, it is failing because of 0% code coverage.
Could you please help me here?
Following is my trigger:
trigger createPriceBookEntry on Product2 (after insert) {
    
    List<priceBookEntry> priceBookEntryList= new List<priceBookEntry>();
    
    String pricebkId= [SELECT id from Pricebook2 where isStandard=true][0].Id;
    
    for(Product2 prod: trigger.new){      
        priceBookEntry priceBkEntry= new priceBookEntry();
        priceBkEntry.Product2Id= prod.Id;
        priceBkEntry.Pricebook2Id= pricebkId;
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = prod.MSOFT_Artikelnummer__c;
        //Add more fields as per requirement
        
        priceBookEntryList.add(priceBkEntry);
    }
    
    if(priceBookEntryList.size()>0)
    {
        insert priceBookEntryList;
    }
}
Following is the test class:
@isTest
public class TestQuoteLineItem
{  
    Static testmethod void insertRecord()
   	{
        priceBookEntry priceBkEntry= new priceBookEntry();
       
        priceBkEntry.Pricebook2Id= '01s09000003qN9eAAE';
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = 'test';
        priceBkEntry.Product2Id = '01t1l000005CY2aAAG';
        //Add more fields as per requirement
            
        insert priceBkEntry;
       
       //system.assertequals(priceBkEntry.Pricebook2Id,priceBkEntry.Pricebook2Id);
       //System.debug('My debug message: ' + priceBkEntry.Product2Id);
   }
}
Thank you so much for your help in advance!
My Trigger is as follows:- 

trigger opportunityAcountTeam on Opportunity (after insert, after update) {
    LIST<Opportunity> listOpp = new LIST<Opportunity>();
    SET<ID> oppIds = new SET<ID>();
    LIST<AccountTeamMember> listAccTeamMember = new LIST<AccountTeamMember>();
    //LIST<AccountShare> listShare = new LIST<AccountShare>();
    if(Trigger.IsAfter && Trigger.IsInsert) {
        for(Opportunity newOpp : Trigger.new) {
            if(newOpp.Probability == 20) { 
                    if(String.isEmpty(newOpp.AccountId)) {
                    newOpp.addError('Account name cannot be blank');
                    return;    
                    }
                listOpp.add(newOpp);
                oppIds.add(newOpp.AccountId);               
                    AccountTeamMember newAccMember = new AccountTeamMember();
                    newAccMember.AccountAccessLevel = 'Edit';
                    newAccMember.OpportunityAccessLevel = 'Read';
                    newAccMember.TeamMemberRole = 'Account Manager';
                    newAccMember.AccountId = newOpp.AccountId;                 
                    newAccMember.UserId = newOpp.OwnerId;
                    newAccMember.Account = newOpp.Account;
                    //AccountShare newAccShare = new AccountShare();
                    //newAccShare.AccountAccessLevel='Read';
                     //newAccShare.OpportunityAccessLevel = 'Read Only';
                     //newAccShare.CaseAccessLevel='Read Only';
                    //newAccShare.AccountId = newOpp.AccountId;
                    //newAccShare.UserOrGroupId = newOpp.OwnerId;                    
                    listAccTeamMember.add(newAccMember);
                    system.debug('team' + listAccTeamMember);
                    //listShare.add(newAccShare);        
                        if(listAccTeamMember != NULL) {
                        insert listAccTeammember;                        
                        }
           }
        }       
    }
}

My test class is as follows:-

@isTest
public class oppAccTeamMember {
    static testMethod Void testOppAccTeamMember() {
        LIST<Opportunity> newOpp = new LIST<Opportunity>();
        LIST<AccountTeamMember> newTeamMember = new LIST<AccountTeamMember>();
        LIST<Account> listAcc = new LIST<ACCOUNT>();
        SET<ID> allIds = new SET<ID>();
        Profile pld= [SELECT Id FROM Profile WHERE Name = 'Standard User' LIMIT 1];
        User u= new User();
        u.LastName = 'ttt';
        u.ProfileId = Pld.Id;        
        insert u;                   
        
        Account newAcc = new Account();
        newAcc.Name = 'Starting';
        newAcc.OwnerId = u.Id;        
        listAcc.add(newAcc);        
        insert listAcc;        
                
        Opportunity createOpp = new Opportunity();       
        createOpp.Name = 'First';
        createOpp.CloseDate = Date.today();
        createOpp.StageName = 'Prospecting';
        createOpp.AccountId = newAcc.Id;
        allIds.add(createOpp.AccountId);
        if(String.isEmpty(createOpp.AccountId)) {
        createOpp.addError('Account name cannot be blank');
        return; 
        }       
       newOpp.add(createOpp);       
       insert newOpp;       
        
        AccountTeamMember createTeam = new AccountTeamMember();
        createTeam.accountId = createOpp.AccountId;
        createTeam.AccountAccessLevel = 'Read';
        createTeam.UserId = createOpp.OwnerId;
        newTeamMember.add(createTeam);        
        insert newTeamMember;       
    }
}

My test class is failing and it is giving me System.DMLException Insert failed

Please provide assistance as I am stuck with for many days and I do not just want to forget about it because by doing that I am not going to learn for the next time.

Thanks
Vijay
Hello Everyone,

I am trying to create a table. using simple SLDS data table. I have suceeessfully created the the table header in <thead >. but the Problem is with <tbody>.

I have create a apex class and wired it into js file to store the data in list. How do I add data in rows from that list into my table ?
Hi, sorry this is kind of a basic question, but I can't find the answer to it: How do you edit a button that has already been created? For example, if there's a custom button on an Accounts record page or Opportunities record page that a previous developer on my team created, how do I open that up to edit it? And what is the quick way to know what Visualforce page is connected to that button? (By edit, I mean the actual logic of the button, not change the layout of where it's located on the page.)
Thanks
@AuraEnabled(cacheable=true)
    public static List<Benefit_Tab__mdt> getBenefitData() {
        List<Benefit_Tab__mdt> benefitTab;
        try {
                if (Benefit_Tab__mdt.sObjectType.getDescribe().isAccessible()) {
                    benefitTab = [Select Masterlabel,DeveloperName,Tab_Description__c,Category__c,
                                    Order__c,CSS_Class__c,Journey_Steps__c
                                    from Benefit_Tab__mdt
                                    where Category__c = 'International'
                                    order by Order__c];
                }
                return benefitTab;
        } catch (QueryException e) {
            throw new AuraHandledException(e.getMessage());
        }
    }

Can any one please help me to write test class for custom meta data class 
I have four fields account,contact,phone and email on visualforce page. when I search the account name which exists in the data base then  those email , phone and contact should update to that account. If not found then create a new account with the following fields.

apex Class


public class CreatingandupdatingaccountcontactRecords {
    public string accountName {get;set;}
    public string contactName {get;set;}
    public string emailId     {get;set;} 
    public string phoneNumber {get;set;}   
    List<Account> accountList   = new List<Account>(); 
    List<Account> upsertAccount = new List<Account>();
    List<Contact> contactList   = new List<Contact>();
    List<Contact> upsertContact = new List<Contact>();
    public void checkAccountsandcontacts() {
        accountList = [select Name from Account where Name =:accountName];
        if(accountList.size() > 0) {
            for(Account  a : accountList ) {
                if(a.Name == accountName) {
                    a.Emai_id__c =emailId;
                    a.Phone = phoneNumber; 
                    upsertAccount.add(a);
                }
            }  
        }  
        if(accountList.size() < 0){ 
            Account newAccount = new Account();
            newAccount.Name = accountName;
            newAccount.Emai_id__c = emailId;
            newAccount.Phone = phoneNumber;
            upsertAccount.add(newAccount);
        } 
        upsert upsertAccount;
        contactList =[select LastName from contact where LastName =:contactName];
        if(contactList.size() > 0) {
            for(contact con : contactList) {
                if(con.LastName == contactName ) { 
                    con.Email = EmailId;  
                    con.Phone = phoneNumber;
                    for(Account a1 : accountList) {
                    con.AccountId = a1.Id;
                    }
                    upsertContact.add(con); 
                } 
            }
        }
        else{
            contact newcontact = new contact();
            newcontact.lastName = contactName;
            newcontact.phone = phonenumber;
            newcontact.Email = EmailId;
            for(Account acc:upsertAccount) {
                newcontact.AccountId = acc.Id;
            }
            upsertContact.add(newcontact);   
        }
        upsert upsertContact;  

        if(accountList.size() > 0){
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info, 'Your record is updated successfully')); 
        }
        if(accountList.size() < 0){
          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.info, 'Your record is created successfully'));  
        }
    }  
}

TestClass : 


@istest
public class contactAccountcreationpage_TC {
    public static testmethod void duplicateEmailerrormessage() {
        String accountName = 'testing account';
        Account acc = new Account();
        acc.Name = 'testing account';
        acc.Emai_id__c = 'dinesh@gmail.com';
        acc.Phone = '842631791';
        insert acc;
        
        Account acc1 = new Account();
        acc1.Name = 'testing account';
        acc1.Emai_id__c = 'dinesh@gmail.com';
        acc1.Phone = '842631791';
        insert acc1;
        
        Contact con = new contact();
        con.LastName = 'vini';
        con.AccountId = acc.Id;
        insert con;
        
        CreatingandupdatingaccountcontactRecords obj = new CreatingandupdatingaccountcontactRecords();
        obj.checkAccountsandcontacts();        
    }
}

 
Hi Pals,

This  test cass keeps throwing an error for

1) For Method "testGetLevel1 " as
System.AssertException: Assertion Failed: Expected: Test Level 1, Actual: null
1) For Method "testsaveCaseType" as
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Level 1: bad value for restricted picklist field: Test Level 1: [Level_1__c]

Here is test class
 
@isTest
public class ERT_MultiLevelSelectEditTest {
  
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct; 

    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
       
   test.startTest();
   List<ERT_MultiLevelSelectEdit.LevelWrapper> lstWrapper= ERT_MultiLevelSelectEdit.getLevel1(obj.id);
   test.stopTest();
   system.assertEquals('Test Level 1', lstWrapper[0].strL1val);
     
   
     
    

   }

  @isTest
   static void testGetLevel2()
   {
   test.startTest();
   List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');
   test.stopTest();
   system.assertEquals('Test Level 2', s[0]);
      
   

   }
    
  @isTest
   static void testGetLevel3()
   {
    test.startTest();
    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');
    test.stopTest();
    system.assertEquals('Test Level 3', s[0]);
   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;

       /*Insert new Case_Type__c Object*/
       Case_Type__c Ctc = new Case_Type__c();
       Ctc.Level_1__c = 'Test Level 1';
       Ctc.Level_2__c = 'Test Level 2';
       Ctc.Level_3__c = 'Test Level 3';
       Ctc.Case__c = cas.id;
       insert Ctc;
      
     
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
       string oldlevel1='OLDone';
       string oldlevel2='OLDtwo';
       string oldlevel3='OLDthree';
       string guid = 'a3k2F000-0007-7JiA-a3k2-000007JiAQAU';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,oldlevel1,oldlevel2,oldlevel3,guid,cas.id);
        test.stopTest();
        system.assertEquals('successfull', testing);
    }
    
 public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public string strERTGuid{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
        
    } 
    
    

}

Here is Apex class
 
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,UniqueGUID__c,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3,strGuid;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
            strGuid=lstertcase[0].UniqueGUID__c;
        }
       
       LevelWrapper guidObj= new LevelWrapper();
       string strERTGuid1=(string)strGuid;
       guidObj.strLevelType='recGUID';
       guidObj.strERTGuid=strERTGuid1;
       lstWrap.add(guidObj);
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string oldlevel1,string oldlevel2,string oldlevel3,string guid,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
 
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            
            else
                obj.id=id;
              upsert  Obj;
            if(oldlevel1 != ''){
            List<Case_Type__c> lstCTD = new List<Case_Type__c>();
            lstCTD=[SELECT id,Level_1__c,Level_2__c,Level_3__c  FROM Case_Type__c WHERE Level_1__c=:oldlevel1 AND Level_2__c=:oldlevel2 
                    AND Level_3__c=:oldlevel3 AND ERTUniqueGUID__c=:guid ];

           

                
            System.debug('Case Type existing data  = '+ lstCTD);
            lstCTD[0].Level_1__c=Obj.Level_1__c;
            
            lstCTD[0].Level_2__c=Obj.Level_2__c;
            
            lstCTD[0].Level_3__c=Obj.Level_3__c;
                
                upsert  lstCTD;
            
          }
            
        
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public string strERTGuid{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

Your help is needed and aappreciated

Fiona


 
I want to create a custom field, the field can to automatically populate information from User, e.g. 

http://mywebsite.com/? n= Lead.Owner.FirstName

Thanks!
 
Dear Pals,

This is the question on including System.Assert statements on existing test class which has 93% code coverage for Apex controller class

Here is the test class,need your help in writing system.debug statments in the below class
 
@isTest
public class ERT_MultiLevelSelectEditTest {
    
  @testSetup static void setup() {
        
    Case_Type_Data__c ct = new Case_Type_Data__c();
    ct.Level_1__c = 'Test Level 1';
    ct.Level_2__c = 'Test Level 2';
    ct.Level_3__c = 'Test Level 3';
    insert ct;      
    }
    
  @isTest
   static  void testGetLevel1()
   {
    
    Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
    insert cas;
    ERT_Case_Type__c  obj = new ERT_Case_Type__c ();
    obj.Level_1__c = 'Test Level 1';
    obj.Level_2__c = 'Test Level 2';
    obj.Level_3__c = 'Test Level 3';
    obj.Case__c = cas.id;
    upsert obj;
    ERT_MultiLevelSelectEdit.getLevel1(obj.id);
    
    

   }

  @isTest
   static void testGetLevel2()
   {

    List<String> s = ERT_MultiLevelSelectEdit.getLevel2('Test Level 1');

   }
    
  @isTest
   static void testGetLevel3()
   {

    List<String> s = ERT_MultiLevelSelectEdit.getLevel3('Test Level 1','Test Level 2');

   }
    
  @isTest 
   static  void testsaveCaseType(){
   
        Case cas = new Case(Status ='New', Priority = 'Medium', Origin = 'Email'); 
        insert cas;
       
        ERT_Case_Type__c obj=new ERT_Case_Type__c();
        string one='one';
        string two='two';
        string three='three';
        test.startTest();
        String testing=ERT_MultiLevelSelectEdit.savecasetype(one,two,three,cas.id);
        test.stopTest();
    }
    

    

}

Here is controller class
 
public class ERT_MultiLevelSelectEdit {
    @AuraEnabled
    public static List<LevelWrapper> getLevel1(string recID){
        List<String> tempLst1 = new List<String>();
        list<LevelWrapper> lstWrap=new list<LevelWrapper>();
        
        list<ERT_Case_Type__c>  lstertcase=new list<ERT_Case_Type__c>();
        lstertcase=[select id,Level_1__c,Level_2__c,Level_3__c from ERT_Case_Type__c where id=:recID];
        string strL1,strL2,strL3;
        if(lstertcase.size()>0){
            strL1=lstertcase[0].Level_1__c;
            strL2=lstertcase[0].Level_2__c;
            strL3=lstertcase[0].Level_3__c;
        }
        
        for(AggregateResult  ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c  group by Level_1__c]) {
            LevelWrapper obj= new LevelWrapper();
            string strLev1=(string)ar.get('Level_1__c');
            obj.strLevelType='recL1';
            obj.strL1val=strLev1;
            if(strLev1==strL1)
                obj.isSelected=true;
            else
                obj.isSelected=false; 
            lstWrap.add(obj);
            
        }

        for(string ar:getLevel2(strL1)){
            if(strL1!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL2';
                obj.strL2val=strLev2;
                if(strLev2==strL2)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        
        for(string ar:getLevel3(strL1,strL2)){
            if(strL2!=null){
                LevelWrapper obj= new LevelWrapper();
                
                string strLev2=(string)ar;
                obj.strLevelType='recL3';
                obj.strL3val=strLev2;
                if(strLev2==strL3)
                    obj.isSelected=true;
                else
                    obj.isSelected=false; 
                lstWrap.add(obj);
            }
        }
        System.debug(' wrapper '+lstWrap);
        return lstWrap;
        
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel2(string strName){
        List<String> tempLst2 = new List<String>();
        for(AggregateResult  ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName  group by Level_2__c])
        {
            tempLst2.add(''+ar.get('Level_2__c'));
        }
        
        return tempLst2;
        
    } 
    
    @AuraEnabled
    public static List<String> getLevel3(string strName1,string strName2){
        List<String> tempLst3 = new List<String>();
        for(AggregateResult  ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c  where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c])
        {
            tempLst3.add(''+ar.get('Level_3__c'));
        }
        
        return tempLst3;
        
        
    } 
    
    @AuraEnabled
    public  static String  savecasetype(string level1,string level2,string level3,string id){
        string strMsg='successfull';
        try{
            ERT_Case_Type__c obj=new ERT_Case_Type__c();
            
            System.debug('CASE  = '+ Obj.Case__c); 
            Obj.Level_1__c=level1;
            System.debug('Level1  = '+ Obj.Level_1__c); 
            Obj.Level_2__c=level2;
            System.debug('Level2  = '+ Obj.Level_2__c); 
            Obj.Level_3__c=level3;
            System.debug('Level3  = '+ Obj.Level_3__c);
            if(id.startsWithIgnoreCase('500'))
                Obj.Case__c = id;
            else
                obj.id=id;
            upsert  obj;
            
        }
        
        catch(Exception ex){
            strMsg='error';
        }
        return strMsg;  
    }
    
    public class LevelWrapper{
        @AuraEnabled
        public string strLevelType{get;set;}
        @AuraEnabled
        public string strL1val{get;set;}
        @AuraEnabled
        public string strL2val{get;set;}
        @AuraEnabled
        public string strL3val{get;set;}
        @AuraEnabled
        public boolean isSelected{get;set;}
        
    }
    
    
    
 }

Regards
Fiona
While clicking button here the page is not navigate to SObject.

Apex Class :
public class ContactListController {

    @auraEnabled
    public static List<contact> getContactList(String accountId){
        List<Contact> ContactList = New List<Contact>([Select Id, FirstName, LastName, Name, Email, phone 
                                                       from contact where Email != null AND AccountId =: accountId ]);
        return ContactList; 
    }
}
Component Class : 
<aura:component Controller="ContactListController" 
                implements="force:hasRecordId,flexipage:availableForAllPageTypes" >
    <aura:attribute name="ContactList" type="Contact[]"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    <div class="slds-p-around_xxx-small">
        <div class="slds-grid slds-wrap">
        <aura:iteration items="{!v.ContactList}" var="con">
        
              <div class="slds-col slds-size_1-of-3 slds-p-around_xxx-small"> 
        <lightning:card footer="{!con.Email}" title="{!con.LastName}" iconName="action:add_contact">
            <aura:set attribute="actions"> 
            <lightning:button name="{!con.Id}" variant="brand" label="View Details" onclick="{!c.DoRedirect}"/>
            </aura:set>
            <p class="slds-p-horizontal_xxx-small">
                {!con.FirstName}&nbsp; {!con.LastName} <br/>
                {!con.phone}
            </p>
        </lightning:card>
            </div>
            
       </aura:iteration>
       </div> 
    </div>   
     
</aura:component>
Controller Class :
({
    doInit : function(component, event, helper) {
        /* Step 1 */
        var action = component.get('c.getContactList');
        /* Step 2 */
        action.setParams({
            accountId : component.get('v.recordId'),
        });
        /* Step 4 */
        action.setCallback(this, function(response){
            var responseValue = response.getReturnValue();
            console.log('responseValue', responseValue);
            component.set('v.ContactList',responseValue)
        }, 'SUCCESS');
        /* Step 4 */
        $A.enqueueAction(action, true);
        
    },
    DoRedirect : function(component, event, helper) {
           var eventsource = event.getsource();
        var id = eventsource.get('v.name'); 
        var navEvt = $A.get("e.force:navigateToSObject");
    navEvt.setParams({
      "recordId": "id",
      "slideDevName": "detail"
    });
    navEvt.fire();
    },
})

Here c.DoRedirect is working or not, plsease suggest me is there any error in the above code.
Hi Everyone,

Looking for some help on how to fix this test class and code coverage issue as I am getting System.NullPointerException: Attempt to de-reference a null object on line 33.

Apex Class:
 
public class MqlService {
    public void setMqlDate(List<sObject> newRecords, Map<Id, sObject> oldRecordsById) {
        List<sObject> records = getOpenRecords(newRecords, oldRecordsById);
        if (records.isEmpty()) {
            return;
        }
        
        BusinessHours hours = [select id from BusinessHours where name = 'MQL Hours'];
        for (sObject record : records) {
            // using this BusinessHours method will set the time to NOW if it is within the business hours
            // otherwise it will set the time to the time the business hours start next
            record.put('Mql_Date__c', BusinessHours.nextStartDate(hours.id, TimeUtils.getNow()));
        }
    }
    
    // returns a list of records that are either inserted as 'Open', or updated to 'Open'
    private List<sObject> getOpenRecords(List<sObject> newRecords, Map<Id, sObject> oldRecordsById) {
        List<sObject> filteredRecords = new List<sObject>();
        for (sObject newRecord : newRecords) {
            if (!recordIsOpen(newRecord)) {
                continue;
            }
            
            if (isInsert(newRecord, oldRecordsById)) {
                filteredRecords.add(newRecord);
                continue;
            }
            
            if (oldRecordsById != null) {
                sObject oldRecord = oldRecordsById.get((Id)newRecord.get('id'));                
                if (oldRecord != null && !recordIsOpen(oldRecord)) {
                    filteredRecords.add(newRecord);                    
                }
            }
        }
        
        return filteredRecords;
    }
    
    private boolean isInsert(sObject newRecord, Map<Id, sObject> oldRecordsById) {
        return oldRecordsById == null || !oldRecordsById.containsKey((Id)newRecord.get('id'));
    }
                
    private boolean recordIsOpen(sObject record) {
        if (record.getSObjectType() == Lead.getSObjectType()) {
            return record.get('Status') == 'Open';
        } else if (record.getSObjectType() == Contact.getSObjectType()) {
            return record.get('Lead_Status__c') == 'Open';
        } else {
            return false;
        }
    }      
}

Test Class:
 
@isTest
public class MqlServiceTest {
    public static testMethod void testSetMqlDate() {
        // retrieve business hours
        BusinessHours hours = [select id from BusinessHours where name = 'MQL Hours'];
        
        // account for contact
        Account account = new Account(name = 'test');
        insert account;

		// lead / contact to update as Open
		Lead updateLead = new Lead(lastName = 'test', company = 'test', email = 'test@test.com', status = 'Pre-MQL');
        Contact updateContact = new Contact(lastName = 'test', accountId = account.id, lead_status__c = 'Pre-MQL');
        insert new List<sObject>{updateLead, updateContact};
            
        // update lead and contact
        updateLead.status = 'Open';
        updateContact.lead_status__c = 'Open';
            
        // lead / contact to insert as Open
        Lead insertLead = new Lead(lastName = 'test', company = 'test', email = 'test@test.com', status = 'Open');
        Contact insertContact = new Contact(lastName = 'test', accountId = account.id, lead_status__c = 'Open');            
            
        // capture the current time to check against business hours, set the time in time utils
        TimeUtils.setNow(Datetime.now());            
        
        // upsert list of leads / contacts to insert / update
        upsert new List<Lead>{insertLead, updateLead};
        upsert new List<Contact>{insertContact, updateContact};
        
        // assert the hour / minutes are correct, since the BusinessHours.nextStartDate doesn't use seconds
        for (Lead lead : [select mql_date__c from lead]) {
        	system.assertEquals(BusinessHours.nextStartDate(hours.id, TimeUtils.getNow()).hour(), lead.mql_date__c.hour());
        	system.assertEquals(BusinessHours.nextStartDate(hours.id, TimeUtils.getNow()).minute(), lead.mql_date__c.minute());            
        }
        
        for (Contact contact : [select mql_date__c from contact]) {
        	system.assertEquals(BusinessHours.nextStartDate(hours.id, TimeUtils.getNow()).hour(), contact.mql_date__c.hour());
        	system.assertEquals(BusinessHours.nextStartDate(hours.id, TimeUtils.getNow()).minute(), contact.mql_date__c.minute());            
        }
    }
}

Because of line 33 assert method filing calls is not getting any code coverage as well.

Thank you for your help. ​​​​​​​

I have two List

List<String> filteredValues = New List<String>();
List<Contract__c> valuesForfilteredValues = something query.

And I have to add them to a map

Map<String, String> detailsMap;

How should I do that.

Scenario.
Let's Say-

The first list has values (Name, City, State);
Second List has values (TestName, Mumbai, MH);
I have to perform dynamically as-

detailsMap.put(Name , TestName);
detailsMap.put(City , Mumbai);
detailsMap.put(State , MH);

Please suggest a way to do this.

The process builder is mapping the RMA field over to a text field on the case. This is the conditional formula portion but will not save due to the error. 

OR(ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Power"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "No Communication (CCM)"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Software"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Assembly defect"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Abuse"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "No problem found"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Other" ), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Connectivity"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Customer Induced Defect (CID)"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "NTF"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "Sound"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "OEM"), ISPICKVAL([Opportunity].RMA_Root_Cause__c, "TBD")), AND($User.Department <> "Accounting"), AND($Profile.Name <> "CG System Administrator"), AND($Profile.Name  <> "System Admin - Custom")))
 
i have 4 checkbox field on an object and 1 pickilist field 



1>    if all four checkbox is checked picklist isequal to all active
2>    if any three checkbox is checked picklist isequal to review
3>    if any two checkbox is checked picklist isequal to approved
4>     if one or none checkbox is checked picklist isequal to rejected
Hi. With the help of another user on the forum, I was able to use a sample test class. I just don't know how or where to add the required fields?

The two required fields that need to be inserted:
Name (Name) *Standard Text field.
Layer (Layer__c) *This is a picklist. The 2 options are "Layer 2" "Layer 3"

Can you please insert them for me?
*I see another area in the test class that says "insert f". I'm not sure what I need to insert in that spot?

Test class:
@isTest
public class FeedCommentTriggerTest {
    
    @isTest
    public static void testFeedCommentTrigger() {
        
        //Create a User with Profile 'Net Planning Department'
        Id pid = [Select Id FROM Profile WHERE Name = 'Net Planning Department'].Id;
        
        User u = new User();
        u.ProfileId = pid;
        //here fill all the required fields for the User Record
        insert u;
        
        SALES_ENGINEERING_REQUEST__c s = new SALES_ENGINEERING_REQUEST__c();
        s.Status__c = //any Value othe than "Approved" and "Unable to Meet Request"
        //here fill all the required fields for the SALES_ENGINEERING_REQUEST__c Record
        insert s;
        
        //Since test class runs in the current user mode and in this Trigger lines will be covered only when the    //User has a Profile - 'Net Planning Department' hence we need trigger this event as the new User created with this //Profile
        System.runAs(u) {
            FeedComment f = new FeedComment();
            f.ParentId = s.Id;
            //here fill all the required fields for FeedCommentRecord
            
            Test.startTest();
            insert f;
            Test.stopTest();
        }
        
        
        SALES_ENGINEERING_REQUEST__c updatedRecord = [SELECT Id,Status__c  FROM SALES_ENGINEERING_REQUEST__c WHERE Id =: s.Id];
        System.assertequals('Approved',updatedRecord.Status__c);
    }
    
}

Thank you for your help!
Hi All,

I want to change the format of my date. Currently, the format is in yyyy-MM-dd but I want it to be like 12th December 2020.

My apex code is currently:

currentDateString = string.valueOf(Date.today());

And in my visualforce page it is:

<apex:outputLabel id="currentDateString" style="color:white;font-size:26px;font-weight:bold">{!currentDateString}</apex:outputLabel>
Hi All,

I am getting a very rookie error. I am not sure why I am getting it however could someone please help?

I am getting the below errors:

User-added image

Code:

User-added image


 
Hi everyone
I am trying to write a validation rule to remind the user to check one field if another one is blank

IF Application Source (which is a text field) is blank then either prompt the user to tick the Internally Applied checkbox or even better, automate the process

Hope this makes sense and thank you in advance

Regards, Leanne
I'm using a great snippet of code created by Jake Backues in the following link: change owner without changing tasks (https://developer.salesforce.com/forums/?id=906F000000091paIAA)

The problem is now testing this.  I'm new at this and have done my best to create a test class.  The problem is, my code coverage is 0%.  Can anyone point me in the right direction on how to get the test class to test the use case?

Trigger:
trigger AccountTrigger on Account (before update, after update) {

    if(Trigger.isBefore) {
        EventUtil.setOwnerIds(Trigger.oldMap, Trigger.newMap);
    }

    if(Trigger.isAfter) {
        EventUtil.updateOwnerIds();
    }
}
Class:
public with sharing class EventUtil {

    /** Event Id => Original Owner Id **/
    public static Map<Id,Id> originalEventOwnerIds = new Map<Id,Id>();

    public static Void setOwnerIds(Map<Id,Account> oldMap, Map<Id,Account> newMap) {

        /** Only process this data if the Account (household) owner changed **/
        Id[] changedAccounts = new Id[]{};
        for(Id hhId : newMap.keySet()) {
            if(oldMap.get(hhId).OwnerId != newMap.get(hhId).OwnerId) {
                changedAccounts.add(hhId);
            }
        }

        for(Event e : [Select Id, WhatId, Subject, OwnerId, Owner.Name from Event where WhatId in :changedAccounts and StartDateTime >= TODAY]) {
            originalEventOwnerIds.put(e.Id, e.OwnerId);
        }
    }

    public static Void updateOwnerIds() {
        
        if(originalEventOwnerIds.isEmpty()) return;

        /** Grab active user list to see if the old user is still active **/
        Map<Id,User> activeUsers = new Map<Id,User>([Select Id, Name from User where IsActive = true and Id in :originalEventOwnerIds.values()]);

        Event[] eventsToUpdate = new Event[]{};
        Event[] allEvents = [Select Id, Subject, OwnerId, Owner.Name from Event where Id in :originalEventOwnerIds.keySet()];
        for(Event e : allEvents) {
            if(originalEventOwnerIds.get(e.Id) != e.OwnerId && activeUsers.keySet().contains(originalEventOwnerIds.get(e.Id))) {
                e.OwnerId = originalEventOwnerIds.get(e.Id);
                eventsToUpdate.add(e);
            }
        }

        if(eventsToUpdate.size() != 0) {
            update eventsToUpdate;
        }
    }
    
}

Test:
@isTest
public class setOwnerTest 
{
    static testMethod void inactiveOwners() 
	{
		Account a = new Account();
			a.Name = 'Test';
        	a.OwnerId = 'testuser';
		insert a;
		
		Contact cont = new Contact();
			cont.FirstName ='test';
			cont.LastName ='Demo';
			cont.accountId = a.id;
		insert cont;
		
        Test.startTest();
			Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
			User usr = new User(Alias = 'standt', Email='standarduser@testorg.com', 
						EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
						LocaleSidKey='en_US', ProfileId = p.Id, 
						TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com');
			insert usr ;
			System.runAs(usr)
			{
				a.ownerId = usr.id;
				update a;
			}
        Test.stopTest();       
    }
}

 
I have created lightning component and 6 fields there, one date field is also there
how can we do that if age is more than 18 years then 2 fields shoud be hide.
Can please someone help me on that...

Thanks in advance
I created a custom text field called "Contract ID Number" and I want to only enter numbers. I was trying to use this formula
OR(LEN(Contract ID Number) <> 20)

But I get Error: Syntax error. Missing ')' I checked and I seem to close everything out properly. I'm pretty new to salesforce so any help would be much appreciated.

*Note: I could have used a number field, but I didn't because of the comma it generate (ex show 2000 instead of 2,000)
  • April 14, 2021
  • Like
  • 0
Hello, I am displaying custom object records in Datatable via @wire, Since account is a lookup, it displays account id instead of account name. How can I display the name of the account in the colum. 

I have tried the following but it doesn't work. Please suggest.
 {
        label: 'My Accounts',
        fieldName:'My_Account__r.Name
        type: 'text',
        sortable: true
  }
 
Hi All,

Exception:-
First error: Row with null Id at index: 0

I am getting an exception while showing the total number of  contacts on the account using batch Apex.Not able to resolve, can somebody help?

public class UpdateAccountwithBatchApex implements Database.Batchable<sObject>,Database.Stateful
{
    
    Public Integer RecordsProcessed=0;
    public Database.QueryLocator Start(DataBase.BatchableContext context)
    {
        return Database.getQueryLocator([Select id from account]);
    }
Public void Execute(Database.batchableContext context,list<Account>scope)
{
Map<Id, AggregateResult> results = new Map<Id, AggregateResult>([SELECT Accountid Ids, COUNT(Id) amt FROM contact WHERE Accountid = :scope GROUP BY Accountid]);
        list<Account>accrec=new list<account>();
         Account acc=new Account();
        for(Account record: scope)
        {
            System.debug('I am in for loop');
            AggregateResult amount = results.get(record.Id);
            if(amount != null)
            {
              System.debug('I am in the if statement');
              
              accrec.add(new Account(Id=(Id)amount.get('ids'),Total_no_of_Contacts__c=(Decimal)amount.get('amt')));  
                
                                 
             }
            else
            {
                
            accrec.add(new Account(Id=(Id)amount.get('ids'),Total_no_of_Contacts__c=null));  
                          
                
            }
}
update accrec ;
 }
        

    public void Finish(Database.BatchableContext de)
    {
 
        
      System.debug('Records processed were'+RecordsProcessed);  
        
        
    }
 
       
 }

Thanks,
 
Boolean.valueOf(newRecord.get('Custom_Field__c')) != Boolean.valueOf(oldRecord.get('Custom_Field__c'))
Hi
Help please, I made the following trigger on Opportunity, where to being in a specific stage, create a record of a random user of a specific profile in the Opportunity Team
This is my trigger
trigger SLInsertOppTeam on Opportunity (before insert, before update) {
	for(Opportunity opp : trigger.New){	
		if(opp.StageName == 'A' && opp.is_new__c == false)
		{
            List<OpportunityTeamMember> member = [SELECT TeamMemberRole FROM OpportunityTeamMember 
                                                  Where OpportunityId = : opp.Id
                                                 AND TeamMemberRole = : 'Analist'];
            if(member.size() == 0 )
            {
				OpportunityTeamMember OTM = new OpportunityTeamMember();
            	OTM.OpportunityId = opp.Id;
				OTM.TeamMemberRole = 'Analist';
				OTM.OpportunityAccessLevel = 'Edit';       
            	List<User> uList = [SELECT Id FROM User Where IsActive = true and ProfileId = '00e4x000000NCX0AAO'];
            	if(uList.size() > 0){
                	Integer Ran = (integer)(Math.random() * (uList.size()));
            		OTM.UserId = uList[Ran].id;
            	}
            	insert OTM; 
             }   
		}   
    }  
}
When doing the trigger test, there is no error and it completes it well, but in the coverage it stays at 0%, could you help me to know what is wrong in the test or know how I can improve it so that it gives me a percentage of coverage feasible for you to take it as good
This is my Test
@isTest
private class SLTestInsertOMT {
    @isTest(SeeAllData=true)
    static void TestInsert() 
    {
        Test.startTest();
        Opportunity opp = [select Id, StageName, is_new__c from Opportunity where id_sf__c = '21022600147' LIMIT 1];
        if(opp.StageName == 'A' && opp.is_new__c == false)
        {
        	OpportunityTeamMember otm = new OpportunityTeamMember (OpportunityId= opp.Id, 
                                                             TeamMemberRole = 'Analist',
                                                             OpportunityAccessLevel = 'Edit',
                                                             UserId ='0054x000004Hu2xAAC');
        	insert otm;
        }
        System.assert(true); 
        Test.stopTest();
    }
}


 
Hello,

I've read and re-read the documentation around using the Navigation Mixin to browse to Community/Experience named pages and I can't get it to work.

I have dom element with a click handler that looks like this:
handleMenuItemClick() {
    console.log("Menu Item clicked: " + this.label + ", pageApiName:" + this.pageApiName);
    var pageRef = {
        type: 'comm__namedPage',
        attributes: {
            name: this.pageApiName
        },
    };
    
    console.log("pageRef: " +     JSON.stringify(pageRef));

    this[NavigationMixin.Navigate](pageRef);
}

The output of printing my PageReference object to the browser console is this:
{"type":"comm__namedPage","attributes":{"name":"Contact_Support"}}

I'm using the API name to identify the Contact Support page.  The documentation says this is supported:
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_navigation_page_definitions.htm

However, it doesn't work and I'm stumped.  Are there any examples how to use the Navigation Mixin to browse to the Contact Support, My Account or Account Management pages?

Thank you,

Chris
hi all,
i'm new with SF and apex, so i don't know how start

i am trying to create a apex class that can map or link the name of a custom object (eg. "test1__c") with the description of de Case Object

So, when the users clicks the name of the custom object, he can see the description of the Case.

I think it starts like this, but I don't know how to continue


Map<test__c,Case> Ticketmap=new Map<test__c,Case>([SELECT description FROM Case];
We use Dates and then Time Windows for our company vs actual times, however for an integration I need to give it a Date/Time value to work properly. I'm creating two Date/Time formulas to hold a Start Date/Time and End Date/Time that it needs.

For whatever reason, my formula isn't working. I have no syntax errors and the formula saves fine, but no values are populating. I thought it was maybe resorting to the NULL value, but I added another Date/Time value rather than null, and it still isn't populating.

Any help is appreciated.
IF(TEXT(Appointment_Time__c)="9-1 (Morning)",
DATETIMEVALUE(
TEXT(YEAR(Appointment_Date__c))
+"-"+
TEXT(MONTH(Appointment_Date__c))
+"-"+
TEXT(DAY(Appointment_Date__c))
+" "+
"9:00:00"
),
IF(TEXT(Appointment_Time__c)="1-5 (Afternoon)",
DATETIMEVALUE(
TEXT(YEAR(Appointment_Date__c))
+"-"+
TEXT(MONTH(Appointment_Date__c))
+"-"+
TEXT(DAY(Appointment_Date__c))
+" "+
"13:00:00"
),
IF(TEXT(Appointment_Time__c)="5-7 (Evening)",
DATETIMEVALUE(
TEXT(YEAR(Appointment_Date__c))
+"-"+
TEXT(MONTH(Appointment_Date__c))
+"-"+
TEXT(DAY(Appointment_Date__c))
+" "+
"17:00:00"
), NULL)))

 
Hello-

We have a junior developer who wrote a very large lightning component that has over 1,000 references to:

<aura:if isTrue="{!v.profileName =='System Administrator'}"

The issue we have is now we need additional profiles, all containing "Admin" in the name to this. Is there a way to copy/replace all so I don't have to go through each individual reference and add || or && conditions to it? Is something like this doable:

<aura:if isTrue="{!CONTAINS(v.profileName, 'Admin'}"

or

<aura:if isTrue="{!v.profileName == '%Admin'}"

In some cases we may need an || condition in some cases we may need an && condition. So i cannot just to a global replace to add the additional profile names here.

Thanks

Hi all,

I try use Salesforce DX create a Scratch Org and use "sfdx force:org:open" command to open it.

Then I reset password for this user. And success reset it. But I can't use test.salesforce.com to login this Scratch Org, it always show error message: Please check your username and password.

May I ask is there any solution to fixed this issue? 

I found same issue in force.com github but it not helped.
https://github.com/forcedotcom/cli/issues/583 

  • April 06, 2021
  • Like
  • 0
Can someone help me with this problem? When I load the component tab then it shows 2 errors: isVpbank is not defined and isHsbcBank is not defined

creditCard.html
<template>
    <template if:true={isVpbank}>
        <img class="image-card" src={vpbankImage}/>
    </template>

    <template if:true={isHsbcBank}>
        <img class="image-card" src={hsbcImage}/>
    </template>
    
    
    <div class="slds-m-around_medium">
        <template if:true={creditCard.data}>
            <template for:each={creditCard.data} for:item="cc">
                <p key={cc.Id}>{cc.Name}</p>
            </template>
        </template>
    </div>

</template>

creditCard.js
import { LightningElement, api, wire } from 'lwc';

import myResource from '@salesforce/resourceUrl/creditCard';
import getCreditCard from '@salesforce/apex/CreditCardController.getCreditCard';
import isVpBankCredit from '@salesforce/apex/CreditCardController.isVpBankCredit';
import isHsbcCredit from '@salesforce/apex/CreditCardController.isHsbcCredit';


const VP_BANK = myResource + '/credit-card-images/vp-bank.jpg';
const HSBC = myResource + '/credit-card-images/hsbc.jpg';

export default class CreditCard extends LightningElement {
    vpbankImage = VP_BANK;
    hsbcImage = HSBC;
    isVpbank = false;
    isHsbcBank = false;
    
    @wire(getCreditCard) creditCard;

    connectedCallback() {
        isVpBankCredit().then((result) => {
            this.isVpbank = result;
            console.log(isVpbank);
        });

        isHsbcCredit().then((result) => {
            this.isHsbcBank = result;
            console.log(isHsbcBank);
        });
    }
}

​​​​​​​
Hi,

Through LWC I am able to display list of records  along with check box in custom table .
Issue is how can I pass only selected records to apex class from lwc like how we pass  from aura component to apex class.

Please someone guide me.
controller:-

({
    doInit : function(component, event, helper) {
           // create a one-time use instance of the serverEcho action
        // in the server-side controller
        var action = component.get("c.getcontact");
        action.setParams({ accountId : component.get('v.recordId'), });
 
        // Create a callback that is executed after 
        // the server-side action returns
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                // Alert the user with the value returned 
                // from the server
                component.set("v.contactname",response.getReturnValue());
                 console.log(response.getReturnValue());
                // You would typically fire a event here to trigger 
                // client-side notification that the server-side 
                // action is complete
            }
            else if (state === "INCOMPLETE") {
                // do something
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                 errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
        });
 
        // optionally set storable, abortable, background flag here
 
        // A client-side action could cause multiple events, 
        // which could trigger other events and 
        // other server-side action calls.
        // $A.enqueueAction adds the server-side action to the queue.
        $A.enqueueAction(action);
    },
    
     doButton : function(component, event, helper) {
        var eventSource = event.getSource();
        var id = eventSource.get(v.name);
        alert(id); 
    }
});

Aura Component:

<aura:component controller="contactclass" implements="flexipage:availableForAllPageTypes,force:hasRecordId">
    
    <aura:attribute name="contactname" type="Contact[]" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
    {!v.recordId}
    <div class="slds-grid slds-wrap">
        <aura:iteration items="{!v.contactname}" var="item" >
              <div class="slds-col slds-size_1-of-3">
                  <div class="slds-p-around_x-small">
                <lightning:card footer="Business Card" title="Cognizant" variant="Narrow"  iconName="standard:employee_asset">
                    <aura:set attribute="actions">
                    
                        <lightning:button variant="brand" name="values"  label="More" title="Brand action" onclick="{!c.doButton }" />                  
                    </aura:set>
                        <p class="slds-p-horizontal_small">
                             {!item.FirstName} &nbsp; {!item.LastName}<br />
                            </p>
                   </lightning:card>
              </div>        
            </div>             
        </aura:iteration>
     
    </div>    
    
</aura:component>

contact class:-
Hello All,
I am new to development. I have written a trigger to add a newly created product into the standard price book. But while deployment to PROD, it is failing because of 0% code coverage.
Could you please help me here?
Following is my trigger:
trigger createPriceBookEntry on Product2 (after insert) {
    
    List<priceBookEntry> priceBookEntryList= new List<priceBookEntry>();
    
    String pricebkId= [SELECT id from Pricebook2 where isStandard=true][0].Id;
    
    for(Product2 prod: trigger.new){      
        priceBookEntry priceBkEntry= new priceBookEntry();
        priceBkEntry.Product2Id= prod.Id;
        priceBkEntry.Pricebook2Id= pricebkId;
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = prod.MSOFT_Artikelnummer__c;
        //Add more fields as per requirement
        
        priceBookEntryList.add(priceBkEntry);
    }
    
    if(priceBookEntryList.size()>0)
    {
        insert priceBookEntryList;
    }
}
Following is the test class:
@isTest
public class TestQuoteLineItem
{  
    Static testmethod void insertRecord()
   	{
        priceBookEntry priceBkEntry= new priceBookEntry();
       
        priceBkEntry.Pricebook2Id= '01s09000003qN9eAAE';
        priceBkEntry.IsActive= True;
        priceBkEntry.UnitPrice= 0; // Dummy Value
        priceBkEntry.UseStandardPrice= False;
        priceBkEntry.External_ID__c = 'test';
        priceBkEntry.Product2Id = '01t1l000005CY2aAAG';
        //Add more fields as per requirement
            
        insert priceBkEntry;
       
       //system.assertequals(priceBkEntry.Pricebook2Id,priceBkEntry.Pricebook2Id);
       //System.debug('My debug message: ' + priceBkEntry.Product2Id);
   }
}
Thank you so much for your help in advance!
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?
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.