• Rod Tyler 38
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
Hello everyone. I know this question has been posted before but wanted to revisit with a fresh set of eyes. So as you know, admins need to search an ENTIRE org's metadata for various reasons. For my use case, I need to find every instance of where the word 'Loan' is being used... (i,e, picklist values, report filters, flows, everything.)

In the past, Eclipse was pretty decent at doing this but, the force.com IDE is no longer available and it is suggested to move to VS Code. Fighting with getting a solid metadata dump through vscode package.xml is making this not a decent solution for this task.(too many errors)

I know there are appexchange apps like Satrang's Metadata Search but, I find that is not finding everything either. OwnBackup seems like it might work too? I JUST NEED A SIMPLE WAY TO FIND MY NEEDLE IN THE METADATA HAYSTACK! Is this too much to ask? 

What are your experiences and tools that work reliably for you?
I am brand new to development so, please don't roll your eyes up too far... :p

I have this trigger I found that does exactly what I need (it appears). I understand everything it is doing except for the syntax here (for(OpportunityLineItem ol: OLI)) and the (update OLI) towards the end. 

Also, I know I need a test class but have no clue what I should test for and how to write it. Any brave soul able to help me out on this?
 
trigger CreateAssetonClosedWon on Opportunity (after insert, after update) {
    for(Opportunity o: trigger.new){
        //Check to see if the opportunity isWon and that it has line items
        if(o.isWon == true && o.HasOpportunityLineItems == true){
            String opptyId = o.id;

            //Query the opportunity line items
            OpportunityLineItem oli = [Select UnitPrice, Quantity, PricebookEntry, Product2Id, PricebookEntry, Product
                from OpportunityLineItem
                where OpportunityId = opptyId];
            
            //Assign values from query to new asset
            Asset ast = new Asset();
            for(OpportunityLineItem ol: OLI){
                a = new Asset();
            a.AccountId = o.AccountId;
                a.Product2Id = ol.PricebookEntry.Product2Id;
                a.Purchase_Opportunity__c = opptyId;
                a.Quantity = ol.Quantity;
                a.Price = ol.UnitPrice;
                a.PurchaseDate = o.CloseDate;
                a.Status = "Active";
                a.Description = oi.Description;
                a.Name = oi.PricebookEntry.Product2.Name;
                ast.add(a);
            }
        update OLI;
        //Creaet the record    
        insert ast;
        }
    }
}