• Olga Kim 7
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 0
    Replies
Hi all,
I wrote a test class (please, see below) that covers most of my code except "catch" part of the code.
Please, help me to figure out what is missing in my apex test class.
public with sharing class SubmitReportUseOfAwardController {
    
    @AuraEnabled
    public static string updateUseOfAward(string recordId){
  
   Use_of_Award__c record=[SELECT id, UOA_Report_Status__c FROM Use_of_Award__c WHERE Id=:recordId];        
       try
    {
    
        record.UOA_Report_Status__c='Submitted';
        update record;
        
        return 'SUCCESS';
    }
        catch(Exception e){
        throw new AuraHandledException(e.getMessage()); 
      }
    }
}

My test class
@isTest
public class SubmitReportUseOfAwardCtrTest {

    @testSetup
    public static void dataInit()
    {
        Account org=new Account();
        org.Name='test';      
        insert org;
        
        Award__c award=new Award__c();
        award.Organization__c=org.Id;
        insert award;
        
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
        
        User u1 = new User(Alias = 'standt1',
                           Country='USA',
                           Email='demo1@randomdemodomain.com',
                           EmailEncodingKey='UTF-8',
                           LastName='Testing',
                           LanguageLocaleKey='en_US',
                           LocaleSidKey='en_US',
                           ProfileId = p.Id,
                           TimeZoneSidKey='America/Los_Angeles',
                           UserName='dprobertdemo1@camfed.org');
        insert u1;
        
        Use_of_Award__c record=new Use_of_Award__c();
        record.UOA_Award__c=award.Id;
        record.Fiscal_Year_Entry__c='2020';
        record.CCME_Analyst__c=u1.Id;
        insert record;
        
    }
    
       
     @isTest
    public static void testUpdateUseOfAwardPositive()
    {
    
        
        string recordId=[SELECT Id from Use_of_Award__c LIMIT 1].id;  
        string result=SubmitReportUseOfAwardController.updateUseOfAward(recordId);
        system.assert(result=='SUCCESS');
        

    }
       @isTest
    public static void testUpdateUseOfAwardNegative()
    {
        try
        {
          SubmitReportUseOfAwardController.getUseOfAwardRecord(null);
            system.assert(false);
        }
          catch(exception e)
        {
           system.assert(true); }
     
    }
    
}

​​​​​​​
Hello 
I need to create a button using aura component that will redirect to VisualForce page but it should open it in new tab.

Is there a way to do it?

Thank you
I started working on a project converting Salesforce org from Classic to Lightning Experience. 
One big part of the project is converting JavaScript Buttons. There are over 130 JS buttons there. I have some understanding of how to convert simple ones but have no idea what to do with those that are more complex like the one below: 
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
var theStatus = "{!Application__c.Application_Status__c}";

if ('{!TODAY() > Application__c.Due_Date__c}'=='true') {
alert("The Application cannot be submitted after the Due Date.");
}
else if ('{!OR(ISBLANK(Application__c.of_Attachment__c),Application__c.of_Attachment__c = 0)}'=='true') {
alert("Please attach the relevant documents in the related attachment section.");
}
else if (confirm("Once Submitted you will not be able to update the application. Do you want to Submit?") == true) {
// identify the record
var a = new sforce.SObject("Application__c");
a.Id = "{!Application__c.Id}";

// make the field change
a.Application_Status__c = 'Submitted';
// save the change
result = sforce.connection.update([a]);
// reload the page
window.location.reload();
} else {
window.location.reload();;
}
}
Please, help me understand:
  • what my first steps should be?
  • where can I find some solutions for converting JS Buttons?
  • Can I use lightning flows to add validation to the buttons?
  • LWC or Aura Component? 
I will appreciate any advice. 
Thank you  
Hello everyone,  
 I got stuck on challenge #5.
 
I get the error "Challenge Not yet complete... here's what's wrong:
We can’t find the correct settings for the h1 related to the boat name in the component boatTile. Make sure the component was created according to the requirements, including styling."

 
<template>
    <div onclick={selectBoat} class={tileClass}>
        <div style={backgroundStyle} class="tile"></div>
            <div class="lower-third">
                <h1 class="slds-truncate slds-text-heading_medium">{boat.Name}</h1>
                <h2 class="slds-truncate slds-text-heading_small">{boat.Contact__r.Name}</h2>
                <div class="slds-text-body_small">
                    Price: <lightning-formatted-number maximum-fraction-digits="2" format-style="currency" 
                    currency-code="USD" value={boat.Price__c}> </lightning-formatted-number>
                </div>
                <div class="slds-text-body_small"> Length: {boat.Length__c} </div>
                <div class="slds-text-body_small"> Type: {boat.BoatType__r.Name} </div>
            </div>
        </div>
    </div>
</template>

Could you help me to figure out what did I do wrong?

Thank you, in advance.


Olga