• SFDC12
  • NEWBIE
  • 119 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 26
    Questions
  • 32
    Replies
Hi experts,using flows Iam trying to create a task to particular user,how to assign to particular user  please help me out
Hi everyone how to navigate to the listview using pagerefrence in salesforce apex,tried many ways please help me out
thanks in advance.
Hi every in production in one object i have a l particular istview for user,i need to have the same in uat ,i tried using dataloader export from prod and imported in UAT ,able to the see diff rec but not the listview which i want for that user,i should login and able to see the listview please help me
Hi experts,i have created a Debug log for the user and then i run the testclass unable to see the debuglogs please help me out

Thanks in advance.
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 I have two objects which have same picklist field if the picklist field selected value is different it should throw an error message please help me out

thanks in advance
 
  • April 21, 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 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;
        }
    }
}
Hi experts,using flows Iam trying to create a task to particular user,how to assign to particular user  please help me out
Hi experts,i have created a Debug log for the user and then i run the testclass unable to see the debuglogs please help me out

Thanks in advance.
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 I have two objects which have same picklist field if the picklist field selected value is different it should throw an error message please help me out

thanks in advance
 
  • April 21, 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.