• Zoren Domingo
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
Hi,

I need to make the {!Opportunity.Name} a hyperlink to the record. How to accomplish this?


User-added image
Hi, can anyone help creating a test class for this aura enabled controller class?
 
public class CampaginScoreCardController {
    
    @AuraEnabled
    public static List<OpportunityLineItem> getOppProds(List<Id> oppIds){
        List<OpportunityLineItem> oppLIList = [Select Id, Gross_UE_Count__c, Data_Vendor__c, Closed_Loop_Analysis__c, Reporting_Length__c, Product2.Name FROM OpportunityLineItem Where OpportunityId in:oppIds AND Product2.Name='Addressable'];
        return oppLIList;
    }
    
    @AuraEnabled
    public static List<Campaign_Scorecard__c> getScorecards(List<Id> oppIds){
        List<Campaign_Scorecard__c> scorecardList = [Select Id, Name, Opportunity__c, Vendor_Measurement__c, Days__c, Primary_KPI__c, Secondary_KPIs__c, Client_Satisfaction__c, Target_Quality__c, OVERALL_RATING__c FROM Campaign_Scorecard__c Where Opportunity__c in:oppIds Order by Vendor_Measurement__c DESC, Days__c ASC];
        return scorecardList;
    }
    
    @AuraEnabled
    public static Opportunity getOpportunity() {
        return [Select Id, Campaign_Name__c, Product_Vertical__c, Reach__c, Frequency__c, Delivery__c, Week__c, Notes__c, Overall_Campaign_Rating__c FROM Opportunity Limit 1];
    }
    
    @AuraEnabled
    public static Map<String,String> saveScorecardList(List<Campaign_Scorecard__c> scorecardList) {
        // Forming a  string map to return response
        Map<String,String> resultMap = new Map<String,String>();
        // Adding try catch for exception handling
        try {
            
            update scorecardList;
            // Setting the success status and message in resultMap
            resultMap.put('status', 'success');
                resultMap.put('message', 'Scorecard Updated Successfully');        
        }
        catch(Exception e) {
            // Setting the success status and message in resultMap
            resultMap.put('status', 'error');
                        resultMap.put('message',e.getMessage());
        }
        // Returning the result string map
        return resultMap;
    }
    
    
}

 
Hi, can anyone help me on making this formula, defaul to 0, if values are blank.

(ROUND((NULLVALUE( Primary_KPI__c , 0) * (0.3 + Adjustment_Factor__c )) + 
      (NULLVALUE( Secondary_KPIs__c,0 ) * (0.1+ Adjustment_Factor__c)) + 
      (NULLVALUE( Client_Satisfaction__c,0 ) * (0.3+ Adjustment_Factor__c)) + 
      (NULLVALUE( Target_Quality__c,0 ) * (0.3+ Adjustment_Factor__c)),1)
Hi, is there a way in lightning can I make a field a hyperlin that directs to the record URL?

This is the formula field, I'm thinking how to convert this in lightning.
HYPERLINK("https://adworks--dev2.lightning.force.com/lightning/r/Campaign_Scorecard__c/" 
& Id 
& "/view" 
,TEXT(Vendor_Measurement__c))
Hi, can anyone help me creating apex trigger for deleting multiple records once a custom field is updated?
Here's my current code.
trigger AdworksTriggerForCampaignScoreCard on OpportunityLineItem (after insert, after update, after delete) {
    
    List<Campaign_Scorecard__c> scorecardToInsert = new List<Campaign_Scorecard__c>();    
    
    public class applicationException extends Exception {}
    try{
    
        
        if(trigger.isUpdate) {
            
            for (OpportunityLineItem oli: trigger.new){
                
                OpportunityLineItem oldOli = Trigger.oldMap.get(oli.ID);
                
                if(oli.Reporting_Length__c != trigger.oldMap.get(oli.ID).Reporting_Length__c){
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 0 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '0';
                        scorecardToInsert.add(cs);
                    }
                    
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 30 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '30';
                        scorecardToInsert.add(cs);
                    }
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 60 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '60';
                        scorecardToInsert.add(cs);
                    }
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 90 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '90';
                        scorecardToInsert.add(cs);
                    }
                }
            }
            
        }
        insert scorecardToInsert;   
    
    }
    catch(Exception e)
    {
        system.debug(e.getMessage());
        throw new applicationException(e.getLineNumber() + '.Please Contact your System Administrator');        
    }
	
	

}

Hi, can anyone can help me, I have little experience with apex trigger, I need to create a record base on the OpportunityLineItem custom field.

Multiple Records to create:

Campaign_Scorecard__c - custom object - Look-up relationship with Opportunity.

Can anyone help me on these? I'm trying to update a field in opportunity after I add a products and also when I remove it.

trigger AdworksTriggerForCampaignScoreCard on Opportunity (after update) {
    
    List<OpportunityLineItem> relatedOppLI = [SELECT Id,Product2.Name FROM OpportunityLineItem
        WHERE OpportunityId IN :Trigger.New];
    
    List<Opportunity> relatedOpps = [SELECT Id,Name,Campaign_Score_Card__c FROM Opportunity];
    
    List<Opportunity> oppsToUpdate = new List<Opportunity>();
    for(OpportunityLineItem oppLI : relatedOppLI) {      
        for(Opportunity opp : relatedOpps){
            if(Trigger.isUpdate){
                if(oppLI.Product2.Name == 'Addressable')
                {          
                    opp.Campaign_Score_Card__c = true;
                    oppsToUpdate.add(opp);
                }
            }
        }
    }
    update oppsToUpdate;
}
Hi, can anyone help me on making this formula, defaul to 0, if values are blank.

(ROUND((NULLVALUE( Primary_KPI__c , 0) * (0.3 + Adjustment_Factor__c )) + 
      (NULLVALUE( Secondary_KPIs__c,0 ) * (0.1+ Adjustment_Factor__c)) + 
      (NULLVALUE( Client_Satisfaction__c,0 ) * (0.3+ Adjustment_Factor__c)) + 
      (NULLVALUE( Target_Quality__c,0 ) * (0.3+ Adjustment_Factor__c)),1)
Hi, can anyone help me creating apex trigger for deleting multiple records once a custom field is updated?
Here's my current code.
trigger AdworksTriggerForCampaignScoreCard on OpportunityLineItem (after insert, after update, after delete) {
    
    List<Campaign_Scorecard__c> scorecardToInsert = new List<Campaign_Scorecard__c>();    
    
    public class applicationException extends Exception {}
    try{
    
        
        if(trigger.isUpdate) {
            
            for (OpportunityLineItem oli: trigger.new){
                
                OpportunityLineItem oldOli = Trigger.oldMap.get(oli.ID);
                
                if(oli.Reporting_Length__c != trigger.oldMap.get(oli.ID).Reporting_Length__c){
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 0 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '0';
                        scorecardToInsert.add(cs);
                    }
                    
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 30 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '30';
                        scorecardToInsert.add(cs);
                    }
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 60 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '60';
                        scorecardToInsert.add(cs);
                    }
                    if(oli.Reporting_Length__c.contains('Closed Loop Analysis (Client Data) Acxiom 90 Days')) {
                        Campaign_Scorecard__c cs = new Campaign_Scorecard__c(Opportunity__c=oli.opportunityId);
                        cs.Vendor_Measurement__c = 'Closed Loop Analysis (Client Data) Acxiom';
                        cs.Days__c = '90';
                        scorecardToInsert.add(cs);
                    }
                }
            }
            
        }
        insert scorecardToInsert;   
    
    }
    catch(Exception e)
    {
        system.debug(e.getMessage());
        throw new applicationException(e.getLineNumber() + '.Please Contact your System Administrator');        
    }
	
	

}

Hi, can anyone can help me, I have little experience with apex trigger, I need to create a record base on the OpportunityLineItem custom field.

Multiple Records to create:

Campaign_Scorecard__c - custom object - Look-up relationship with Opportunity.

Can anyone help me on these? I'm trying to update a field in opportunity after I add a products and also when I remove it.

trigger AdworksTriggerForCampaignScoreCard on Opportunity (after update) {
    
    List<OpportunityLineItem> relatedOppLI = [SELECT Id,Product2.Name FROM OpportunityLineItem
        WHERE OpportunityId IN :Trigger.New];
    
    List<Opportunity> relatedOpps = [SELECT Id,Name,Campaign_Score_Card__c FROM Opportunity];
    
    List<Opportunity> oppsToUpdate = new List<Opportunity>();
    for(OpportunityLineItem oppLI : relatedOppLI) {      
        for(Opportunity opp : relatedOpps){
            if(Trigger.isUpdate){
                if(oppLI.Product2.Name == 'Addressable')
                {          
                    opp.Campaign_Score_Card__c = true;
                    oppsToUpdate.add(opp);
                }
            }
        }
    }
    update oppsToUpdate;
}