• SFDC12
  • NEWBIE
  • 124 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 30
    Replies
Hi everyone, i need to fecth account related contacts which has only attachments ,please help me out

Thanks in Advance.
Hi everyone,whenever account owner is changed related opportunity owner should not change please help me out


Thanks in Advance
  • April 28, 2022
  • Like
  • 0
Hi everyone Iam able to send mail when update happens in account related contact details but i need to get only one mail it contains these many contacts but am getting how many contacts means that many mails.ishould get only one mail says u have these may contacts please help,tried so far..
  

Trigger:
trigger semdmailfromacc on Account (after update) {
set<id> AccIds = new set<id>();
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
for(Account Acc: trigger.new){
AccIds.add(Acc.Id);
}
list<Contact> Con = [Select Id,Accountid,FirstName,LastName,Email from Contact Where AccountId in :AccIds];
for(Contact cc: Con){
if (cc.Email != null && cc.FirstName != null) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(cc.Email);
mail.setToAddresses(sendTo);
mail.setSubject('Contact Details');
String body = 'Dear'+cc.LastName+ '<a href="'+URL.getSalesforceBaseUrl().toExternalForm()+'/'+cc.id+'">Click Here</a>';
body += 'This is the Account';
body += 'related Contact ';
body += 'with details.';
mail.setHtmlBody(body);
mails.add(mail);
}
}
Messaging.sendEmail(mails);
}
  • April 15, 2022
  • Like
  • 0
Hi every one,how to edit and existing record in lwc i used record edit form but it creates a new record but i need to edit the existing record please help.


Thanks in Advance.
  • March 30, 2022
  • Like
  • 0
Hi everyone,when i clcik on the button it opens like a form able to perform save and cancel ,but record edit form object api name is different but  i need to place this component in account record page due to differ in obj it doesnot show the fields please help me

html:
<template>
<lightning-button label="show popup" onclick={handlePopup}></lightning-button>
   <div class="chart slds-m-around_medium" lwc:dom="manual"></div>
   
   <template if:true={modalPopUpToggleFlag}>
   
     <section
       id="modal"
       role="dialog"
       tabindex="-1"
       aria-labelledby="modal-heading-01"
       aria-modal="true"
       aria-describedby="modal-content-id-1"
       class="slds-modal slds-fade-in-open"
     >
       <div class="slds-modal__container">
         <header class="slds-modal__header">
           <button
             class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
             title="Close"
           >
             <svg
               class="slds-button__icon slds-button__icon_large"
               aria-hidden="true"
             >
               <use
                 xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"
               ></use>
             </svg>
             <span class="slds-assistive-text">Close</span>
           </button>
           <h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">
             Modal Header
           </h2>
         </header>
         <div
           class="slds-modal__content slds-p-around_medium"
           id="modal-content-id-1"
         >
           <div class="slds-p-bottom_large slds-p-left_large" style="width:500px">
             <lightning-record-edit-form
               id="recordViewForm"
               record-id={recordId}
               object-api-name="Bokking__c"
             >
               <lightning-messages></lightning-messages>
               <lightning-input-field field-name="Name"> </lightning-input-field>
               <lightning-input-field field-name="country__c"> </lightning-input-field>
               <lightning-input-field field-name="State__c">
               </lightning-input-field>
               <lightning-input-field field-name="price__c"> </lightning-input-field>
 
               <lightning-button
                 type="submit"
                 label="Update record"
                 class="slds-m-top_medium"
               >
               </lightning-button>
             </lightning-record-edit-form>
           </div>
         </div>
         <footer class="slds-modal__footer slds-modal__footer_directional">
           <button class="slds-button slds-button_neutral" onclick={handleSkip}>
             Skip This Step
           </button>
         </footer>
       </div>
     </section>
     <div
       class="slds-backdrop slds-backdrop_open modalBackdrops"
       id="modalBackdrops"
     ></div>
   </template>
js:
 export default class lwcTask extends NavigationMixin (LightningElement) {
  modalPopUpToggleFlag = false;
 
      handlePopup(){
          this.modalPopUpToggleFlag = true;
      }
 
      handleSkip(){
          this.modalPopUpToggleFlag = false;
      }
}
  • March 29, 2022
  • Like
  • 0
Hi every am able to open a custom model form when click on a button when click on save it should save in the particular object ,please help.

html:
<template>
<lightning-card title="Display a Custom Popup/Modal In Salesforce Lightning Web Component -- LWC" icon-name="custom:custom20">
 
  <!-- lightning button for open custom modal window -->
  <lightning-button variant="brand"
  label="Open Custom Modal Popup in LWC"
  title="Open Modal"
  onclick={customShowModalPopup}
  class="slds-m-left_x-small"></lightning-button>
   
  <!-- modal start -->        
  <template if:true={customFormModal}>
   
  <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
  <div class="slds-modal__container">
      <!-- modal header start -->
      <header class="slds-modal__header">
          <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={customHideModalPopup}>
              <lightning-icon icon-name="utility:close"
              alternative-text="close"
              variant="inverse"
              size="small" ></lightning-icon>
              <span class="slds-assistive-text">Close</span>
          </button>
          <h2 class="slds-text-heading_medium slds-hyphenate">Custom Modal Popup in LWC</h2>
      </header>
      <!-- modal body start -->
      <div class="slds-modal__content slds-p-around_medium">
   
      <div class="slds-grid slds-wrap">
          <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Name"></lightning-input>
          </div>
  <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Phone" ></lightning-input>
          </div>
  <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Email"></lightning-input>
          </div>
  <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Designation"></lightning-input>
          </div>
  </div>
  <!-- modal footer start-->
      <footer class="slds-modal__footer">
          <button class="slds-button slds-button--destructive" onclick={customHideModalPopup}>Cancel</button>
          <button class="slds-button slds-button_brand">Save</button>
      </footer>
  </div>
  </div>
  </section>
  <div class="slds-backdrop slds-backdrop_open">
  </div>
  </template>
  <!-- modal end -->
   
  <br/> <br/>
 
   
   
   
  </lightning-card>  
  </template>

js:
import { LightningElement, api,track } from 'lwc';
export default class LightningRecordFormEditExampleLWC extends LightningElement {
     
    @track customFormModal = false;
   
    customShowModalPopup() {            
        this.customFormModal = true;
    }
 
    customHideModalPopup() {    
       
        this.customFormModal = false;
    }
   
}
 thanks in Advance.
  • March 29, 2022
  • Like
  • 0
Hi experts ,how to prevent duplicate child (contact)records having same name related to particular account if contact lastname has same throws an error message.


Thanks in Advance.
  • February 10, 2022
  • Like
  • 0
Hi experts when am trying to deploy the trigger am hitting below error ,please help  me to resolve .thanks in Advance.
First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception (Guest users cannot be record owners. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, field integrity exception (Guest users cannot be record owners
  • February 02, 2022
  • Like
  • 0
Hi everyone Iam very new to salesforce trying to clone opportunity and opportunityLineitem but unable to see the result correctly,Below is the code which i have tried..

class:
public class cloneoppandopplineitem {
    public static void oppmethod(List<id>oppid){
    opportunity  opp=[select id,name,stageName,closeDate from opportunity where id=:oppid];
        opportunity oppinse=opp.clone(false);
        system.debug('1-->'+oppinse);
        oppinse.StageName='prospecting';
        insert oppinse;
        system.debug('2-->'+oppinse);
        
        opportunityLineItem oli=[select Product2.name,opportunityId, Product2Id,Quantity from OpportunityLineItem where opportunityId=:oppid];
        system.debug('3-->'+oli);
        opportunityLineItem ol=oli.clone(false);
        ol.OpportunityId=oppinse.id;
        insert ol;
        system.debug('4-->'+ol);
    }
}
  • December 17, 2021
  • Like
  • 0
Hi everyone,
Below trigger and testclass ,trigger working fine ,there is no code coverage for the trigger,what am missing in testclass,can someone plz help me out.

Trigger,
trigger updatephonebasedonaddress1 on Account (after update) {
List<contact>conlist=new List<contact>();
set<Id>accid=new set<id>();
    for(Account a:trigger.new){
        accid.add(a.id);
    }
    List<Account>acclist=[select id,name,phone,BillingCountry,(select id,Phone,LastName,MailingCountry from contacts)from Account where id=:accid];
    for(Account a:acclist){
        for(contact c:a.contacts){
            if(c.MailingCountry==a.BillingCountry){
                c.phone=a.phone;
                conlist.add(c);
            }
        }
        update conlist;
    }
}

Testclass:

@isTest
public class Testupdatephonebasedonaddress1 {
@isTest
static void clme(){
Account a=new Account();
a.Name='test';
a.BillingCountry='inr';
a.Phone='2328938';
insert a;
Contact c=new Contact();
c.LastName='conname';
c.MailingCountry='inr';
c.AccountId=a.Id;
insert c;
Test.startTest();
List<Contact> con=[select id,name,phone from Contact where Accountid=:a.Id];
con[0].phone=a.Phone;
update con;

Test.stopTest();
}
}
  • November 09, 2021
  • Like
  • 0
Hi everyone,below is the trigger and testclass which i have written.ablw to cover 70% can some one plz help me to increase the code coverage.
trigger:
trigger updateoppstage on Account (after update) {
set<id> accountId=new set<id>();
    
   
    for(Account a:trigger.new){
        accountId.add(a.id);
    }
    //query the account related opp
    List<opportunity>opp=new list<opportunity>();
   List<opportunity>opplist=[select id,name,stageName,createdDate,Accountid from opportunity where Accountid=:accountid];
    for(opportunity o:opplist){
        if(o.stageName!='ClosedWon'&&  o.CreatedDate<system.today()){
            o.stageName='ClosedLost';
        }
        opp.add(o);
    }
    update opp;
}
testclass:
@isTest
public class Testupdateoppstage {
@isTest
    static void call(){
        Account a=new Account();
        a.name='testacc';
         insert a;
        opportunity o=new opportunity();
        o.name='testopp';
        o.StageName='needanalysis';
        o.CloseDate=system.today();
        //o.CreatedDate=2-2-2021;
        o.AccountId=a.id;
       
        Test.startTest();
       List<opportunity>opp=[select id,accountId,stageName,name,closeDate,createdDate from opportunity where accountid=:a.id];
       
        update a;
         o.stageName='ClosedLost';
        update opp;
        //system.assertEquals(o.stageName, 'ClosedLost');
        Test.stopTest();
        
    }
}

Thanks in advance
  • November 05, 2021
  • Like
  • 0
Hi ,how to perform pagination in lwc with inlineedit .

Thanks in Advance
  • September 28, 2021
  • Like
  • 0
Hi everyone tried below trigger which is working fine but testclass failed,can someone help me out.

Trigger:
//when opportunity is inserted opportunityLineItem with one product associated should insert
trigger Insertingoppandoppline on Opportunity (after insert) {
 Pricebook2  standardPb = [select id, name, isActive from Pricebook2 where  IsStandard = true limit 1];
    
    Product2 prd1 = new Product2 (); // ----> Create  product
    prd1.Name='myproduct';
    insert prd1;
    
    PricebookEntry pbe1 = new PricebookEntry ();  //------->Create PriceBookEntry
    pbe1.Product2ID=prd1.id;
    pbe1.Pricebook2ID=standardPb.id;
    pbe1.UnitPrice=50;
    pbe1.isActive=true;
    insert pbe1;
    
    List<OpportunityLineItem>  oplist=new List<OpportunityLineItem>(); //-->Create List to store OpportunityLineItem
    
    for(Opportunity opp: Trigger.New)
    {
        OpportunityLineItem oppli = new OpportunityLineItem(); //---->Create OpportunityLineItem.
        oppli.PricebookEntryId=pbe1.Id;
        oppli.OpportunityId = opp.Id;
        oppli.Quantity = 5;
        oppli.TotalPrice = 10.0;
       oplist.add(oppli);
    } 
    insert oplist; //----->insert OpportunityLineItem
}
testclass:
@isTest
public class Testinsertoppandoppline {
@isTest
    static void invoke(){
       PricebookEntry PBE=[select id from PricebookEntry limit 1 ];
Opportunity opp= new Opportunity();
opp.name='testOpp';
opp.closeDate=system.today()+20;
opp.stageName='Qualification';
try{
insert opp;
}
catch(Exception e){
System.debug(e);
}

List<opportunitylineitem> opppro = new opportunitylineitem[]{new opportunitylineitem(UnitPrice=10000.00, Quantity=10, opportunityid=opp.id, pricebookEntryId=PBE.id),new opportunitylineitem(UnitPrice=10000.00,     Quantity=10,  opportunityid=opp.id, pricebookEntryId=PBE.id),new opportunitylineitem(UnitPrice=10000.00,     Quantity=10,  opportunityid=opp.id, pricebookEntryId=PBE.id),new opportunitylineitem(UnitPrice=10000.00,     Quantity=10,  pricebookEntryId=PBE.id, opportunityid=opp.id)};
insert opppro;

    }
}
  • September 16, 2021
  • Like
  • 0
Hi evryone tried  below code and testclass able to cover 80% how to cover error message.
Trigger:
//write a trigger only system administrator should delete the tasks(if system administartor means delete the recrd if not show error message)
trigger userdeletetasks on Task (before delete) {
id profileid=userinfo.getProfileId();
    profile profilname=[select Name from Profile where id=:profileid];
    for(task t:trigger.old){
        if(profilname.Name!='System Administrator'){
            t.adderror('no access for user');
        }
    }
  
}

Testclass:
@isTest
public class Testuserdeletetasks {
@isTest
    static void call(){
        
      task t=new task();
        t.Subject='subtask';
        insert t;
         Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
       
            try{
                delete t;
            }catch(Exception ex){
                system.debug('Exception');
               
                system.assert(ex.getMessage().contains('no access for user'),'no access for user');
            }    
        
        
    }
}

Thanks in Advance.
  • September 15, 2021
  • Like
  • 0
Hi everyone how to add colors to the listviews in records based on the particular field.
  • September 15, 2021
  • Like
  • 0
Hi everyone,am trying to create a contact related to paritcular account in lightning .tried so far..,and embeded this component in accountrecord page ,but unable to save. can someone help me out .

Thanks in Advance.
apex:
public class QuickCreatecontact {
@AuraEnabled
    public static void createcontact(contact con,Id AccountId){
        con.AccountId=AccountId;
        insert con;
    }
}

component:
<aura:component controller="QuickCreatecontact" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    <aura:attribute name="createcontact" type="contact"/>
    <aura:attribute name="accountId" type="string"/>
   <!-- <aura:handler name="init" value="{!this}" action="{!c.doinit}"/>-->
    <div>
        <lightning:input type="text" name="{!v.createcontact.LastName}" label="Enter LastName" />
        <lightning:input type="text" name="{!v.createcontact.FirstName}" label="Enter firstName"/>
        <lightning:input type="phone" name="{!v.createcontact.phone}" label="Enter phone"/>
        
    </div>
    <div>
        <lightning:button label="save" variant="brand" onclick="{!c.dosave}"/>
     </div>
</aura:component>

js:
({
    dosave : function(component, event, helper) {
        var action=component.get("c.createcontact");
        action.setParams({
            con:component.get("v.createcontact"),
            Id:component.get("v.accountId")
        });
        action.setCallback(this,function(response){
            var state=response.getState();
           
            if(state==='SUCCESS'){
                var result=response.getReturnValue();
               alert('SUCCESS');
                
               
            }else if(state==='INCOMPLETE'){
                
            }
        });
        $A.enqueueAction(action);
    }
})
  • September 13, 2021
  • Like
  • 0
Hi every my scenario is to display the opportunity picklist in dropdown based on the picklist we select related records should display and if we click on update ,it should update ihave tried so far ,able to display picklist values but unable to display the records,below is the code

Apex:
public class opp1 {
    public List<SelectOption>options {set;get;}
    public List<opportunity>opportunities {set;get;}
    public List<oppwrapper>oppwraplist {set;get;}
    public string selected {set;get;}
    public opp1(){
       options=new List<SelectOption>();
        opportunities=new List<opportunity>();
        oppwraplist=new List<oppwrapper>();
        List<string>stagevalues=new List<string>{'prospecting','price/quote','need Analysis'}; 
            for(string op:stagevalues){
             SelectOption eachstage=new SelectOption(op,op);
               options.add(eachstage); 
            }
    }
    public void updatestages(){
        List<opportunity>opportunities=new List<opportunity>();
        for(oppwrapper ow:oppwraplist){
            if(ow.flag){
                ow.opp.stageName='selected';
                opportunities.add(ow.opp);
            }
        }
        
    }
    public class oppwrapper{
        public opportunity opp {set;get;}
         public boolean flag {set;get;}
    }    
    

}

vf:
<apex:page controller="opp1" >
    <apex:form >
        <apex:pageBlock >
            
      
           <apex:selectList value="{!selected}" size="1">
               <apex:selectOptions value="{!options}">
               </apex:selectOptions> 
               
            </apex:selectList>
            <apex:pageBlockSection >
                <apex:pageBlockTable value="{!opportunities}" var="a">
                <apex:column value="{!a.name}"/>
                <apex:column value="{!a.stageName}"/>
                <apex:column value="{!a.Amount}"/>
                
            </apex:pageBlockTable>
            </apex:pageBlockSection>
      
             <apex:pageBlockSection >
            <apex:commandButton value="update" action="{!updatestages}"/>
        </apex:pageBlockSection>
            
        </apex:pageBlock>
       
    </apex:form>
    
</apex:page>
  • September 01, 2021
  • Like
  • 0
Hi everyone ,using aura component how to display the modal popup on the contact record whose name starts with test.

Thanks in advance
  • August 28, 2021
  • Like
  • 0
Hi everyone,below is the trigger and testclass  which i have written .
Trigger:
trigger updaterecords on Contact (before insert, before update, after insert, after update) {

List<Contact> conList =new List<Contact>();
    Set<Id> setid = new  Set<Id>();
  
    if(trigger.isBefore){
        system.debug('trigger before event');
        conList = trigger.new;
      
    }else if(trigger.isAfter){
         conList=trigger.new;
        for(Contact con:conList){
           setid.add(con.AccountId);
        }
        system.debug('setid ' + setid);
      
        List<Account> accList = [Select Id, Name, email__c From Account  Where Id=:setid];     
     
        if(trigger.isInsert){                   
          
             for(Contact c1:trigger.new){
                 for(Account a1:accList){
                     a1.email__c= c1.email;
                     update a1;
                 }
              }   
          
        }else if(trigger.isupdate){
            for(Contact c2:trigger.new){
                for(Account a2:accList){
                    a2.email__c= c2.email;
                    update a2;
                }
            }           
        }      
       
    }
}
Testclass:Is this is a crct way of writing the testclass for the above trigger,can someone help me in testclass

testclass:
@isTest
public class updaterecordsTest {
@isTest
    static void call(){
        Account a=new Account();
        a.name='testacc';
        a.Email__c='test@gmail.com';
        insert a;
        contact c=new contact();
        c.LastName='testlastName';
        c.FirstName='testfirstName';
        
        c.AccountId=a.id;
        insert c;
        Test.startTest();
        List<Account> acc=[select id,name,Email__C,(select id,LastName,firstName,Email from contacts)from Account where id=:a.id];
        //a.Email__c=c.Email;
        update acc;
        Test.stopTest();
    }
}
  • August 27, 2021
  • Like
  • 0
Hi everyone, can someonehelp how to write testclass for the below class

@RestResource(urlmapping='/v1/Accountmanager/')
global class Integration_Example {
@HttpGet
    //which is used to get the records or query the records
    global static Account doget(){
        //intilaise the object
       Account a=new Account();
        //get the req parameters in map
        map<string,string> paramsmap=Restcontext.request.params;
        //get the id
        string accid=paramsmap.get('Id');
        //query the records
        a=[select id ,name from Account where id=:accid];
        return a;
    }
    @HttpDelete
    global static Account doDelete(){
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String AccNumber = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE AccountNumber = :AccNumber ];
        delete result;
        return result;
    }
   @Httppost
    //post method is used to create the record
    global static Account docreate(string name){
        Account a = new Account(name=name);
        insert a;
        return a;
    }
     @Httpput
    global static Account doupdate(string name){
        map<string,string> paramsmap=Restcontext.request.params;
        //get the id
        string accid=paramsmap.get('Id'); 
        Account a = new Account(name=name, id=accid);
        update a;
        return a;
    }
}

Thanks in Advance
  • August 17, 2021
  • Like
  • 1
Hi everyone, can someonehelp how to write testclass for the below class

@RestResource(urlmapping='/v1/Accountmanager/')
global class Integration_Example {
@HttpGet
    //which is used to get the records or query the records
    global static Account doget(){
        //intilaise the object
       Account a=new Account();
        //get the req parameters in map
        map<string,string> paramsmap=Restcontext.request.params;
        //get the id
        string accid=paramsmap.get('Id');
        //query the records
        a=[select id ,name from Account where id=:accid];
        return a;
    }
    @HttpDelete
    global static Account doDelete(){
       RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String AccNumber = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE AccountNumber = :AccNumber ];
        delete result;
        return result;
    }
   @Httppost
    //post method is used to create the record
    global static Account docreate(string name){
        Account a = new Account(name=name);
        insert a;
        return a;
    }
     @Httpput
    global static Account doupdate(string name){
        map<string,string> paramsmap=Restcontext.request.params;
        //get the id
        string accid=paramsmap.get('Id'); 
        Account a = new Account(name=name, id=accid);
        update a;
        return a;
    }
}

Thanks in Advance
  • August 17, 2021
  • Like
  • 1
Hi everyone,can someone help how to write testclass for the below code..
Thanks in Advance.

public class Displayrelatedlists {
    //1.list of wrapperclass
     public list<AccountContactWrapper> lstAccountContactWrapper { get; set; }
    public list<AccountContactWrapper> lstSelectedAccountContactWrapper { get; set; }
    //list for selecting the account records
    public list<account> selectedAccounts{get;set;} 

    public Displayrelatedlists () {
        //Allocating the memory for the list
        lstSelectedAccountContactWrapper = new list<AccountContactWrapper>();
        if(lstAccountContactWrapper == null) {
            //allocate memory for the wrapperlist
            lstAccountContactWrapper = new list<AccountContactWrapper>();
            for(account a:[select id,name,phone,(select id,name from contacts)from account limit 10]) {
                lstAccountContactWrapper.add(new AccountContactWrapper(a));
            }
        }
    }
 
    public void ProcessSelected() {
        lstSelectedAccountContactWrapper =new list<AccountContactWrapper>();
        selectedAccounts =new list<Account>();
        for(AccountContactWrapper wrapobj:lstAccountContactWrapper){
            if(wrapobj.isSelected==true) {
                selectedAccounts.add(wrapobj.acc);
            } 
        }
       
        for(Account acc:[select id,name,phone,(select id,name from contacts) from account where id in:selectedAccounts]) {
            lstSelectedAccountContactWrapper.add(new AccountContactWrapper(acc)); 
        }
             
    }
    public class AccountContactWrapper {
 
        public Account acc {get;set;}
        public boolean isSelected {get;set;}
   
        public AccountContactWrapper(account a) {
            acc = a;
            isselected=false;
        }
    }
}
I need to create a validation rule on opportunity to check the close date to be within 365 days after the opportunity created date, can anyone help
Hi !
I have a use case where I have to assign a task to a Queue using record triggered flow. Also show me how to notify user about task assignment and how a user can claim the queued task.

Please help me in this.

Thanks in advance !
Hi everyone,whenever account owner is changed related opportunity owner should not change please help me out


Thanks in Advance
  • April 28, 2022
  • Like
  • 0
Hi every am able to open a custom model form when click on a button when click on save it should save in the particular object ,please help.

html:
<template>
<lightning-card title="Display a Custom Popup/Modal In Salesforce Lightning Web Component -- LWC" icon-name="custom:custom20">
 
  <!-- lightning button for open custom modal window -->
  <lightning-button variant="brand"
  label="Open Custom Modal Popup in LWC"
  title="Open Modal"
  onclick={customShowModalPopup}
  class="slds-m-left_x-small"></lightning-button>
   
  <!-- modal start -->        
  <template if:true={customFormModal}>
   
  <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
  <div class="slds-modal__container">
      <!-- modal header start -->
      <header class="slds-modal__header">
          <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={customHideModalPopup}>
              <lightning-icon icon-name="utility:close"
              alternative-text="close"
              variant="inverse"
              size="small" ></lightning-icon>
              <span class="slds-assistive-text">Close</span>
          </button>
          <h2 class="slds-text-heading_medium slds-hyphenate">Custom Modal Popup in LWC</h2>
      </header>
      <!-- modal body start -->
      <div class="slds-modal__content slds-p-around_medium">
   
      <div class="slds-grid slds-wrap">
          <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Name"></lightning-input>
          </div>
  <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Phone" ></lightning-input>
          </div>
  <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Email"></lightning-input>
          </div>
  <div class="slds-col slds-size_6-of-12 slds-p-horizontal--medium slds-m-bottom_medium">
              <lightning-input label="Designation"></lightning-input>
          </div>
  </div>
  <!-- modal footer start-->
      <footer class="slds-modal__footer">
          <button class="slds-button slds-button--destructive" onclick={customHideModalPopup}>Cancel</button>
          <button class="slds-button slds-button_brand">Save</button>
      </footer>
  </div>
  </div>
  </section>
  <div class="slds-backdrop slds-backdrop_open">
  </div>
  </template>
  <!-- modal end -->
   
  <br/> <br/>
 
   
   
   
  </lightning-card>  
  </template>

js:
import { LightningElement, api,track } from 'lwc';
export default class LightningRecordFormEditExampleLWC extends LightningElement {
     
    @track customFormModal = false;
   
    customShowModalPopup() {            
        this.customFormModal = true;
    }
 
    customHideModalPopup() {    
       
        this.customFormModal = false;
    }
   
}
 thanks in Advance.
  • March 29, 2022
  • Like
  • 0
Hi experts ,how to prevent duplicate child (contact)records having same name related to particular account if contact lastname has same throws an error message.


Thanks in Advance.
  • February 10, 2022
  • Like
  • 0
Create a map populate it with two records Odd and Even. Run a loop from 1-50, if you find an even number increase the count for an even named record in the map or else increase the count of odd named record. Odd and even are keys, counts are values. Example map syntax: Map<String,integer> CountNumber = new map<String,Inetger>({'Even':4},{'Odd':3});

my code is this

public class NumberTest {
    integer oddCount = 0;
    integer evenCount = 0;
    
    Map<string,integer> countNumber = new Map<string,integer>();
    
    for(int i=1;i<=50;i++)
    {
        if(a[i] % 2 != 0){
            countNumber.put('Odd',oddCount++);
        }
        else{
            countNumber.put('Even',evenCount++);
        }
    }
}
Hi everyone Iam very new to salesforce trying to clone opportunity and opportunityLineitem but unable to see the result correctly,Below is the code which i have tried..

class:
public class cloneoppandopplineitem {
    public static void oppmethod(List<id>oppid){
    opportunity  opp=[select id,name,stageName,closeDate from opportunity where id=:oppid];
        opportunity oppinse=opp.clone(false);
        system.debug('1-->'+oppinse);
        oppinse.StageName='prospecting';
        insert oppinse;
        system.debug('2-->'+oppinse);
        
        opportunityLineItem oli=[select Product2.name,opportunityId, Product2Id,Quantity from OpportunityLineItem where opportunityId=:oppid];
        system.debug('3-->'+oli);
        opportunityLineItem ol=oli.clone(false);
        ol.OpportunityId=oppinse.id;
        insert ol;
        system.debug('4-->'+ol);
    }
}
  • December 17, 2021
  • Like
  • 0
Hi, i have created a dashboard and converted it into pdf using visualforce code, now that visualforce pdf need to be scheduled and sent as email using apex class. like scheduling visulaforce using apex class. will that be possible? 
i need to display account details using aura component and i should display only 10 records in one page and i should have 2 buttons that is PREVIOUS PAGE and NEXT PAGE to switch between previous page and next page.How to do this??
Hi everyone,
Below trigger and testclass ,trigger working fine ,there is no code coverage for the trigger,what am missing in testclass,can someone plz help me out.

Trigger,
trigger updatephonebasedonaddress1 on Account (after update) {
List<contact>conlist=new List<contact>();
set<Id>accid=new set<id>();
    for(Account a:trigger.new){
        accid.add(a.id);
    }
    List<Account>acclist=[select id,name,phone,BillingCountry,(select id,Phone,LastName,MailingCountry from contacts)from Account where id=:accid];
    for(Account a:acclist){
        for(contact c:a.contacts){
            if(c.MailingCountry==a.BillingCountry){
                c.phone=a.phone;
                conlist.add(c);
            }
        }
        update conlist;
    }
}

Testclass:

@isTest
public class Testupdatephonebasedonaddress1 {
@isTest
static void clme(){
Account a=new Account();
a.Name='test';
a.BillingCountry='inr';
a.Phone='2328938';
insert a;
Contact c=new Contact();
c.LastName='conname';
c.MailingCountry='inr';
c.AccountId=a.Id;
insert c;
Test.startTest();
List<Contact> con=[select id,name,phone from Contact where Accountid=:a.Id];
con[0].phone=a.Phone;
update con;

Test.stopTest();
}
}
  • November 09, 2021
  • Like
  • 0
How to write a  trigger to update each contact's phone using Account's phone if contact's Mailing country is equal to Account's Billing Country.
  • November 09, 2021
  • Like
  • 0
Hello all, I'm following up an institute's class videos for salesforce lightning. The institute's lecturer showed a simple hello lightning component and called that component in lightning app. I followed the same but it is showing an error as
 " Field Integrity Exception - Failed to save FirstApp.app: Invalid component 'c:FirstComponent.cmp': Source"
 
The Component Code with name FirstComponent:
<aura:component >
  Hello Lightning
 </aura:component>
 
I'm trying to call the component in the Application with name FirstApp as
 <aura:application > 
    <c:FirstComponent.cmp />
 </aura:application>
 
This is the exact code I'm writing from the class but why its not working ? The class videos are from 2020.