• vinni shree
  • NEWBIE
  • 110 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 17
    Questions
  • 25
    Replies
Hi I'm trying to clone Event of one custom object along with event relations.could someone please help me with the code, I'm able to clone event along with nly one contact(relationid) but culdn't clone all the contacts please suggest 
 

HI,

Do we get PD2 certificate if we attempt PD2 certification exam first and then complete superbadges or do we need to maintain the sequence compulsorily
Thank you

Hi,

Can anyone please help what this error means. I didn't understand and stuck on this.

I'm getting this for pricebook and product object related code

 EXCEPTION_THROWN [4]|System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

Thank you

Hi,

 To test the org data in the test class for which sobject we use seeAllData= true. Is it for profile or report. I worked for report ewith seealldata =true but few resources mentioned profile don't need seealldata=true for test class we can directly get the org data.Please clarify 

Thank you

Hi,
I have one custom object now when user creates record it should be inserted in the custom object and it should relate to the existing contact and this contact has one external ID field so this custom record should relate it to the external ID filed now should I use insert followed by an update or can I use upsert on the custom object by specifying the relationship of external object.
Thank you 

Hi,

Using postman I made a rest api call and now I have a requirement to show that data in a screen in salesforce. So how do I store that data in salesforce.

Thank you

Is there any way to create test report data in test class instead of using seealldata=true? 

Thank you

An Approval Process is dened in the Expense_Item__c object. A business rule dictates that whenever a user changes the Status to ` ̃Submitted' on an
Expense_Report__c record, all the Expense_Item__c records related to the expense report must enter the approval process individually.
Which approach should be used to ensure the business requirement is met?
A. Create a Process Builder on Expense_Report__c with an 'Apex' action type to submit all related Expense_Item__c records when the criteria is met.
B. Create a Process Builder on Expense_Report__c to mark the related Expense_Item__c as submittable and a trigger on Expense_Item__c to submit the records for approval.
C. Create two Process Builders, one on Expense_Report__c to mark the related Expense_Item__c as submittable and the second on Expense_Item__c to submit the records for approval.
D. Create a Process Builder on Expense_Report__c with a 'Submit for Approval' action type to submit all related Expense_Item__c records when the criteria are met.

Can anyone explain the correct process for the above question I think using process builder approval action we can submit only one record I'm not aware of related records.

 

Thank you

A developer needs to update an unrelated object when a record gets saved. Which two trigger types should the developer create? (Choose two.)
A. after insert
B. before update
C. before insert
D. after update

Can someone please explain me the correct answer for this.

Thank you

I have fetched records, what i want is if no records are fetched then noaccounts value should be set to false but i'm unable yo do it 

Here is my code please help

handleSearchKeyword() {
if (this.searchValue !== '') {
getAccountList({
searchKey: this.searchValue
})
.then(result => {
this.accounts = result;
console.log(this.accounts);
})
.catch(error => {
});
}
}

Thank you

Hi I have a usecase where a contact record should be removed from lightning component (In UI ) but not from the table on click of button(contactremove).Is this possible in any way please let me know how to do it,

Thank you 

Can someone please explain me when we use connected callback and wire methoda with small use case scenario, I know the defintiions of both but unable to use those at the right time.

 

Thank you 

Hi i wrote this code and getting this error. what I wanted to do is there is checkbox field on account so when user checks that field then all its duplicate accounts have to be merged to this main account on which checkbox is enabled but I am getting this error :Merge requires a concrete SObject type: List<Account>

I didn't understand this. please help me Thanks in advance

This is my code

 

Public class MergeAcct{
Public static void invoke(list<account> accounts){
    list<account> masterAcct=new list<account>();
    for(Account a: accounts){
        if(a.Merge__c==true){
            masterAcct.add(a);
        }
    }
    list<account> acclist=[select id, name, Merge__c from account];
    
   
    for(account acc:masterAcct){
        for(account dupacc:acclist)
        {
            if(acc.Name==dupacc.Name && dupacc.Merge__c==false){
                Merge masterAcct dupacc;
            }
        
            
        
    }  
    }
}
}

Trigger 

 

trigger mergetrig on Account (after insert, after update) {
   MergeAcct.invoke(Trigger.new);
}

Hi i have use case scenario where all the duplicate accounts should be merged with the one main account and its associated contacts also dhould be added to main account 

I'm unable to find the correct approach for it please help me with the code or approach.

Thank you

Hi I have  scenario - Create a checkbox field on Account – “Merge”.
Whenever that checkbox is true get the Account with same email(Consider this account as Duplicate) and assign all related contacts, cases, opportunities to the Main Account(On which checkbox is True) and deactivate user related to the contact assosciated to duplicate account and  Delete duplicate account
So first i tried starting from merging accounts only got this error 
FATAL_ERROR System.DmlException: Merge failed. First exception on row 0 with id 0015i00000SmnhvAAB; first error: INVALID_ID_FIELD, The master record id 0015i00000SmnhvAAB appears in the merge id list: []

Please help me with this 

Code

public class MergeDuplicates {
    public static void invoke(List<account> acc){
    list<account> accounts = [select id, name,Merge__c from account];
        for(account a: accounts){
            if(a.Merge__c==true)
            {  
                list<account> dupacc=[select name, id from account where Name=:a.Name];
                 Merge a dupacc;
                
            }
           
        }
    }

}

Trigger
trigger Mergetrig on Account (after insert, after update) {
    MergeDuplicates.invoke(Trigger.new);
}

Thank you

Hi i have written code, this is a trigger which executes whenever  the Account is updated check all opportunities related to the account. Update all Opportunities Stage to close lost if an opportunity created date is greater than 30 days from today and stage not equal to close won.
I got the logic right but didn't undersatnd how to write test class for this scenario. Please help on this. Thanks in advance 

Apex class

public class Example{
    public static void invoke(list<Account> ac){
    List<Account> accounts =[select id, name from Account];
list<opportunity> opptoup = new list<opportunity>();
for(Account a:[select Id, name,(select Id, name,stagename from opportunities) from Account where Id IN:accounts]){
    for(opportunity op:a.opportunities){
        opptoup.add(op);
        }
}
for(opportunity rec: opptoup){
    if(rec.stagename!='closed won' && rec.stagename!='closed lost' && rec.CreatedDate>system.NOW()+30){
        rec.stagename='closed won';
    }
}
update opptoup;
    }
}

Trigger

trigger exa on Account (after update) {
  Example.invoke(Trigger.new);
}

Test class
@istest
public class useCase7Test {
    @istest
    static void testMe(){
        Account acc= new Account();
        acc.Name='doremon';
        acc.phone='1234';
        insert acc;
        Opportunity opp= new opportunity();
        opp.AccountId=acc.Id;
        opp.StageName='prospecting';
       Datetime mon=datetime.now().addDays(-30);
        test.setCreatedDate(opp.Id,mon);
        opp.CloseDate=date.newInstance(2022, 11, 3);
        opp.Name='firstopp';
        insert opp;
        opportunity opp1= new opportunity();
        opp1.AccountId=acc.Id;
        opp1.StageName='closed lost';
        Datetime mon1=datetime.now().addDays(-30);
        test.setCreatedDate(opp1.Id,mon);
        opp1.CloseDate=date.newInstance(2022,12, 31);
        opp1.Name='secondopp';
        insert opp1;
      list<opportunity> ops =[select name, stagename from opportunity where accountid =: acc.Id];
        system.debug(ops);
        
          }

}

 

I wrote test class till here, able to fetch the opportunities but not able to check with the assertequals method 
 

 

Hi, I have written a code which is trigger that works whenever amount in opportunity is updated or inserted it should be 10% less than the actual entered value. I'm getting this error please help why this error is showing up. Thanks in advance Apex code
 
public class Usecase10 {    
 public static void invoke(list <opportunity> opportunities){         
Map<id, Opportunity> oppAmountUpdate= new Map<Id, opportunity>(); 
Map<Id, Double> oppmap= new Map<Id, Double>(); 
for(opportunity o:[select id, Amount from opportunity]){     
if(o.Amount!=null){     
o.Amount=o.amount-(o.amount*0.1);         
oppmap.put((id)o.get('Id'),(Double)o.get('Amount')); 


for(Id ids:oppmap.keySet()){     
Opportunity opp=new opportunity();     
opp.id=ids;     
opp.Amount=oppmap.get(ids);     
oppAmountUpdate.put(opp.id,opp); 

update oppAmountUpdate.values();     
}  
}
 
Trigger 
 
rigger Usecase10 on Opportunity (after insert, after update) {    
 public static boolean recursive=false;     if(!recursive){        
 recursive=true;       
Usecase10.invoke(Trigger.new); 

}
Hi I'm trying to clone Event of one custom object along with event relations.could someone please help me with the code, I'm able to clone event along with nly one contact(relationid) but culdn't clone all the contacts please suggest 
 
Hi,
I have one custom object now when user creates record it should be inserted in the custom object and it should relate to the existing contact and this contact has one external ID field so this custom record should relate it to the external ID filed now should I use insert followed by an update or can I use upsert on the custom object by specifying the relationship of external object.
Thank you 

Hi,

Using postman I made a rest api call and now I have a requirement to show that data in a screen in salesforce. So how do I store that data in salesforce.

Thank you

Is there any way to create test report data in test class instead of using seealldata=true? 

Thank you

I have fetched records, what i want is if no records are fetched then noaccounts value should be set to false but i'm unable yo do it 

Here is my code please help

handleSearchKeyword() {
if (this.searchValue !== '') {
getAccountList({
searchKey: this.searchValue
})
.then(result => {
this.accounts = result;
console.log(this.accounts);
})
.catch(error => {
});
}
}

Thank you

Hi I have a usecase where a contact record should be removed from lightning component (In UI ) but not from the table on click of button(contactremove).Is this possible in any way please let me know how to do it,

Thank you 

Can someone please explain me when we use connected callback and wire methoda with small use case scenario, I know the defintiions of both but unable to use those at the right time.

 

Thank you 

Hi i wrote this code and getting this error. what I wanted to do is there is checkbox field on account so when user checks that field then all its duplicate accounts have to be merged to this main account on which checkbox is enabled but I am getting this error :Merge requires a concrete SObject type: List<Account>

I didn't understand this. please help me Thanks in advance

This is my code

 

Public class MergeAcct{
Public static void invoke(list<account> accounts){
    list<account> masterAcct=new list<account>();
    for(Account a: accounts){
        if(a.Merge__c==true){
            masterAcct.add(a);
        }
    }
    list<account> acclist=[select id, name, Merge__c from account];
    
   
    for(account acc:masterAcct){
        for(account dupacc:acclist)
        {
            if(acc.Name==dupacc.Name && dupacc.Merge__c==false){
                Merge masterAcct dupacc;
            }
        
            
        
    }  
    }
}
}

Trigger 

 

trigger mergetrig on Account (after insert, after update) {
   MergeAcct.invoke(Trigger.new);
}

Hi I have  scenario - Create a checkbox field on Account – “Merge”.
Whenever that checkbox is true get the Account with same email(Consider this account as Duplicate) and assign all related contacts, cases, opportunities to the Main Account(On which checkbox is True) and deactivate user related to the contact assosciated to duplicate account and  Delete duplicate account
So first i tried starting from merging accounts only got this error 
FATAL_ERROR System.DmlException: Merge failed. First exception on row 0 with id 0015i00000SmnhvAAB; first error: INVALID_ID_FIELD, The master record id 0015i00000SmnhvAAB appears in the merge id list: []

Please help me with this 

Code

public class MergeDuplicates {
    public static void invoke(List<account> acc){
    list<account> accounts = [select id, name,Merge__c from account];
        for(account a: accounts){
            if(a.Merge__c==true)
            {  
                list<account> dupacc=[select name, id from account where Name=:a.Name];
                 Merge a dupacc;
                
            }
           
        }
    }

}

Trigger
trigger Mergetrig on Account (after insert, after update) {
    MergeDuplicates.invoke(Trigger.new);
}

Thank you

Hi i have written code, this is a trigger which executes whenever  the Account is updated check all opportunities related to the account. Update all Opportunities Stage to close lost if an opportunity created date is greater than 30 days from today and stage not equal to close won.
I got the logic right but didn't undersatnd how to write test class for this scenario. Please help on this. Thanks in advance 

Apex class

public class Example{
    public static void invoke(list<Account> ac){
    List<Account> accounts =[select id, name from Account];
list<opportunity> opptoup = new list<opportunity>();
for(Account a:[select Id, name,(select Id, name,stagename from opportunities) from Account where Id IN:accounts]){
    for(opportunity op:a.opportunities){
        opptoup.add(op);
        }
}
for(opportunity rec: opptoup){
    if(rec.stagename!='closed won' && rec.stagename!='closed lost' && rec.CreatedDate>system.NOW()+30){
        rec.stagename='closed won';
    }
}
update opptoup;
    }
}

Trigger

trigger exa on Account (after update) {
  Example.invoke(Trigger.new);
}

Test class
@istest
public class useCase7Test {
    @istest
    static void testMe(){
        Account acc= new Account();
        acc.Name='doremon';
        acc.phone='1234';
        insert acc;
        Opportunity opp= new opportunity();
        opp.AccountId=acc.Id;
        opp.StageName='prospecting';
       Datetime mon=datetime.now().addDays(-30);
        test.setCreatedDate(opp.Id,mon);
        opp.CloseDate=date.newInstance(2022, 11, 3);
        opp.Name='firstopp';
        insert opp;
        opportunity opp1= new opportunity();
        opp1.AccountId=acc.Id;
        opp1.StageName='closed lost';
        Datetime mon1=datetime.now().addDays(-30);
        test.setCreatedDate(opp1.Id,mon);
        opp1.CloseDate=date.newInstance(2022,12, 31);
        opp1.Name='secondopp';
        insert opp1;
      list<opportunity> ops =[select name, stagename from opportunity where accountid =: acc.Id];
        system.debug(ops);
        
          }

}

 

I wrote test class till here, able to fetch the opportunities but not able to check with the assertequals method