• Akash Deokar
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies
Error to complete challenge 3(Create reports for the Support team) of Lightning Experience Reports & Dashboards Specialist superbadge.

Error: Challenge Not yet complete... here's what's wrong:
We can’t find a report with name 'SolarBot Status Averages' in the correct folder, or it uses an incorrect report type.


I have created custom report with only primary object as SolarBot Status and stored in Status Report under SolarBot Support Reports.
 
can we call future method from batch apex?
Please explain in brief what needs to known to execute it.
 
I have written trigger on opportunity as below, if opportunity stage gets update to verbal agreement then SAP CODE and LEGAL ENTITY should be available or it will through error.

But output is not getting as i wanted, please check below logic from code and output. 

Apex Trigger:
trigger SAP_CODE on Opportunity (before Update) {
   for(Opportunity opp:trigger.new){
           
        if(opp.StageName=='Verbal Agreement'){
            System.debug('Stage is verbal');
            
            if(opp.Legal_Entity_Name__r.Name==null){
                System.debug('inside entity name');
                opp.addError('Oppotunity cannot move to 80% as LE is not present');
                
                 If(opp.Legal_Entity_Name__r.SAP_CODE__c==null){
                    opp.addError('Oppotunity cannot move to 80% as SAPE CODE is not present');
                    System.debug('SAP code not available');
                }
            }
            else{
            system.debug('SAP code is available');
            }
        }
    }
}

Code to run trigger:
Opportunity opp= new Opportunity(name='demo', stagename='Qualification', closedate=system.today());
Account demoacc=[Select id from Account where name='Demo Account'];
opp.accountid=demoacc.id;
insert opp;
System.debug('opp inserted');
opp.stagename='verbal agreement';
try{
update opp;
}catch(Exception e)
{e.getmessage();}
Legal_Entity__c LEDemo = new Legal_Entity__c();
insert LEDemo;
opp.Legal_Entity_Name__c=LEDemo.id;
System.debug('LE inserted');
try{
update opp;
}catch(Exception e)
{e.getmessage();}
LEDemo.SAP_CODE__c='0008';
system.debug('SAP CODE updated');
try{
update opp;
}catch(Exception e)
{e.getmessage();}

Output:
User-added image
I have written before update trigger on opportunity but it is not working for below code, not providing error when changing stage to verbal agreement.

Note: I have created one opportunity stage as verbal agreement(80%).

for(Opportunity opp:[Select id,name, Legal_Entity_Name__r.SAP_CODE__c,StageName from opportunity where (StageName='Verbal Agreement' and id in:trigger.new)]){
        if(opp.Legal_Entity_Name__r.SAP_CODE__c==null && opp.Legal_Entity_Name__r.Name==null){
            opp.addError('Oppotunity cannot move to 80% as SAP CODE or LE is not present');


For below code there is error occured as mentioned in code but error is getting for all the stages instead of verbal agreement.

trigger SAP_CODE on Opportunity (before Update) {
    
    Set<Opportunity> updatedoppty = new Set<Opportunity>();
    for (Opportunity opp: trigger.new){
        updatedoppty.add(opp);
    }  
    
    Map<id,Opportunity> mapopty = new Map<id,Opportunity>();
    mapopty.putAll([Select id, name, Legal_Entity_Name__r.SAP_CODE__c,StageName from opportunity where (StageName='Verbal Agreement' and id in:updatedoppty)]);
    
    For (Opportunity opp: trigger.new){
        
        if(null==mapopty.get(opp.Legal_Entity_Name__r.name)){
             opp.addError('Oppotunity cannot move to 80% as LE is not present');
        }
        if(null==mapopty.get(opp.Legal_Entity_Name__r.SAP_CODE__c))
        {
               opp.addError('Oppotunity cannot move to 80% as SAP CODE is not present');
        }
    } 


 
I have created one lookup field of custom object(Legal Entity) on opportunity object. Now i want records of opportunity where SAP code field is blank on Legal Entity Object.

I have written query as below but it is not getting executed.

Select id, name, Legal_Entity__r.SAP_CODE__c from opportunity

Error:Didn't understand relationship 'Legal_Entity__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
I have written trigger on opportunity as below, if opportunity stage gets update to verbal agreement then SAP CODE and LEGAL ENTITY should be available or it will through error.

But output is not getting as i wanted, please check below logic from code and output. 

Apex Trigger:
trigger SAP_CODE on Opportunity (before Update) {
   for(Opportunity opp:trigger.new){
           
        if(opp.StageName=='Verbal Agreement'){
            System.debug('Stage is verbal');
            
            if(opp.Legal_Entity_Name__r.Name==null){
                System.debug('inside entity name');
                opp.addError('Oppotunity cannot move to 80% as LE is not present');
                
                 If(opp.Legal_Entity_Name__r.SAP_CODE__c==null){
                    opp.addError('Oppotunity cannot move to 80% as SAPE CODE is not present');
                    System.debug('SAP code not available');
                }
            }
            else{
            system.debug('SAP code is available');
            }
        }
    }
}

Code to run trigger:
Opportunity opp= new Opportunity(name='demo', stagename='Qualification', closedate=system.today());
Account demoacc=[Select id from Account where name='Demo Account'];
opp.accountid=demoacc.id;
insert opp;
System.debug('opp inserted');
opp.stagename='verbal agreement';
try{
update opp;
}catch(Exception e)
{e.getmessage();}
Legal_Entity__c LEDemo = new Legal_Entity__c();
insert LEDemo;
opp.Legal_Entity_Name__c=LEDemo.id;
System.debug('LE inserted');
try{
update opp;
}catch(Exception e)
{e.getmessage();}
LEDemo.SAP_CODE__c='0008';
system.debug('SAP CODE updated');
try{
update opp;
}catch(Exception e)
{e.getmessage();}

Output:
User-added image
I have written before update trigger on opportunity but it is not working for below code, not providing error when changing stage to verbal agreement.

Note: I have created one opportunity stage as verbal agreement(80%).

for(Opportunity opp:[Select id,name, Legal_Entity_Name__r.SAP_CODE__c,StageName from opportunity where (StageName='Verbal Agreement' and id in:trigger.new)]){
        if(opp.Legal_Entity_Name__r.SAP_CODE__c==null && opp.Legal_Entity_Name__r.Name==null){
            opp.addError('Oppotunity cannot move to 80% as SAP CODE or LE is not present');


For below code there is error occured as mentioned in code but error is getting for all the stages instead of verbal agreement.

trigger SAP_CODE on Opportunity (before Update) {
    
    Set<Opportunity> updatedoppty = new Set<Opportunity>();
    for (Opportunity opp: trigger.new){
        updatedoppty.add(opp);
    }  
    
    Map<id,Opportunity> mapopty = new Map<id,Opportunity>();
    mapopty.putAll([Select id, name, Legal_Entity_Name__r.SAP_CODE__c,StageName from opportunity where (StageName='Verbal Agreement' and id in:updatedoppty)]);
    
    For (Opportunity opp: trigger.new){
        
        if(null==mapopty.get(opp.Legal_Entity_Name__r.name)){
             opp.addError('Oppotunity cannot move to 80% as LE is not present');
        }
        if(null==mapopty.get(opp.Legal_Entity_Name__r.SAP_CODE__c))
        {
               opp.addError('Oppotunity cannot move to 80% as SAP CODE is not present');
        }
    } 


 
I have created one lookup field of custom object(Legal Entity) on opportunity object. Now i want records of opportunity where SAP code field is blank on Legal Entity Object.

I have written query as below but it is not getting executed.

Select id, name, Legal_Entity__r.SAP_CODE__c from opportunity

Error:Didn't understand relationship 'Legal_Entity__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
I'm having issues with Challenge 3. I put the screenshots if someone need.
User-added imageUser-added image

This is the error mensage:
Challenge Not yet complete... here's what's wrong:
The 'SolarBot Status Averages' report is displaying cumulative data.