• Chris Henson2
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi All, 

I know there are ways to do what I'm outlining here, but the ones that I know are kind of ugly and involve double for-loops and the like. I'm trying to streamline this code a little, so I'm looking for a more efficient method.  

Desired Functionality:
Taking a SOQL query of a custom metadata object, returning 2 text fields, and comparing this to a list of objects.  If value1 == the object parameter we're looking for, then replace it with  value2.  

Current Code:

(This is currently in the process of being revised, so it currently does not work, and has been 'scrubbed of actual data, so if some syntax is off, it is not the cause of my issue)
List<custObj__c> relatedList = [Select oldValue from custObj__c];

if(relatedList.size() > 0){
         
         //******This is not correct, and does not work*****       
         Map<String, String> z = new Map<String, String>([SELECT value1__c, value2__c FROM X__mdt WHERE isActive__c=True]);     
//*********//
                              
         if(z != null) {
             for(custObject__c related : relatedList){ 
                  if(z.contains(related.oldValue)){
                        related.oldValue = z.get(related.oldValue);                          
                  }
             }
         }
         Database.update(relatedList, true);
}

So the question is: Is there a way to create a Map to use in the manner I'm trying to above that would not involve creating another for-loop to populate it?
Hi all,

I am working on the LWC Specialist Superbadge Challenges. For my component BoatTile, the Boat pictures are supposed to load up on the page. See screenshot below- 
Boat Picture Issue

This is the piece of code for that-
    get backgroundStyle() { 
      return "background-image:url(${this.boat.Picture__c})";}

Please have a look! Thanks!
Hi all,

I am working on the LWC Specialist Superbadge Challenges. For my component BoatTile, the Boat pictures are supposed to load up on the page. See screenshot below- 
Boat Picture Issue

This is the piece of code for that-
    get backgroundStyle() { 
      return "background-image:url(${this.boat.Picture__c})";}

Please have a look! Thanks!