• bhanu prakash 350
  • NEWBIE
  • 30 Points
  • Member since 2021

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 6
    Replies
Hello Everyone. Does anyone knows how to avoid copy paste of password and email using ara:component and ui:inputText ? and at the same time how to add tooltip pour symbol information(i) ?   
Hello Community! Hope im finding you all doing alright.
Im studying apex and im kind of stuck in a Trail about bulk triggers.
I've found the answer to the challenge in another post but i want to know what is wrong with my approach since i dont seem to understand, would someone explain what is wrong with my code?
i've wrote the following:


Create a bulkified Apex trigger that adds a follow up task to an opportunity if its stage is Closed Won. Fire the trigger after inserting or updating an opportunity.
Name: ClosedOpportunityTrigger
Object: Opportunity
Events: after insert and after update
Condition: Stage is Closed Won
Operation: Create a task:
Subject: Follow Up Test Task
WhatId = the opportunity ID (associates the task with the opportunity)

 
trigger ClosedOpportunityTrigger on Opportunity (after insert, after update) {
    List<Opportunity> oppIDs = [SELECT Id FROM Opportunity WHERE id IN :Trigger.New];
    for (Opportunity opp: oppIDs){
        if (opp.StageName == 'Closed Won'){
            Task newTask = new Task();
            newTask.Subject = 'Follow Up Test Task';
			newTask.WhatId = opp.Id;
            insert newTask;
        }
    }

Thank you so much in advance!
public void createSubexampleOnExample(List<ID> opportunityId, Map<ID,ID> oppLot){
        
        for(Id oppId : opportunityId){
            List<sub_Example__c> subExamples = new List <sub_Example__c>();
            List<Opp_Account_Relationship__c> acc = [Select Account__c, Opportunity__c from Opp_Account_Relationship__c where Opportunity__c =: oppId];
                
            for(Opp_Account_Relationship__c oppAcc : acc){
                sub_Example__c sub = new sub_Example__c();
                sub.Example__c = oppLot.get(oppAcc.Opportunity__c);
                sub.Account__c = oppAcc.Account__c;
                lotAccounts.add(sub);
            }
            insert subExamples;
        }
        
}

Hi all-

Beginning developer that has been running my head into the wall with this trigger for a while now.  I feel like I am missing something obvious but I don't know where it is.

I have reciently implemented Campaign Influence for my organization.  (for those of you who have not used Campaign Influence - it is related to the Opportunity and Contact Roles.  When a contact role is related to an opportunity, the Campaign influence will pull in the Campaigns related to the contact so they are automatically associated to the campaign.)

I have a requirement that all Campaigns related to a contact must be split equally.  I've tried various ways to pull the Query of related campaign influences, but have found that when I attempt to do a bulk upload, the trigger will combine campaigns two different opps, then divide by the total.

(ie. Opp 1 has 3 related campaign influence and opp 2 has 3 related campaign influence.  Instead of attributing 33% influence to each, I end up with 17%).

 

The below trigger works, but I understand that the trigger should not be in the loop and I would like to improve it.

Thank you!

trigger UpdateOppPrimaryCampaign on Opportunity (after update) {
    	
    	for(Opportunity o : trigger.new)  {
            List<String> oppListId = new List<String>();
        	system.debug('First for loop runs');
        	oppListId.add(o.Id);
			system.debug('oppListId = '+oppListId);
            List<CampaignInfluence> relatedCampaignInfuence = [SELECT Id, CampaignId, Influence, OpportunityId FROM CampaignInfluence WHERE OpportunityId IN :oppListId]; 
        	List<CampaignInfluence> campaignInfluenceListUpdate = new List<CampaignInfluence>();
        	    system.debug('relatedCampaignInfuence = '+relatedCampaignInfuence);
        	
            for(campaignInfluence c : relatedCampaignInfuence){        
            	Decimal numCampaign = relatedCampaignInfuence.size();
            		system.debug ('numCampaign = ' + numCampaign);
           		Decimal percentCampaign =  100 / numCampaign;
            		system.debug ('percentCampaign = '+ percentCampaign);
                 c.Influence = percentCampaign;
            	system.debug('c.Influence = '+ c.Influence);
           	     c.Influenced__c = percentCampaign;
            	campaignInfluenceListUpdate.add(c);
            	system.debug('campaignInfluenceListUpdate = ' + campaignInfluenceListUpdate);
                }
        system.debug('update campaignInfluenceListUpdate EXECUTES');
        Database.SaveResult[] results = Database.update(campaignInfluenceListUpdate, false);
            }

}
 

 

 

 

Hello Everyone. Does anyone knows how to avoid copy paste of password and email using ara:component and ui:inputText ? and at the same time how to add tooltip pour symbol information(i) ?