You need to sign in to do that
Don't have an account?
Rafael.Martins.Santos
How get the data of the fields of an Opportunity Updated?
Hi,
I creating a trigger, that when an Opportunity are closed, I get some of the data of the fields of that opportunity and send these informations to another system.
But I don't know how get theses fields with APEX.
Can someone help me?
Best Regards
Rafael
I creating a trigger, that when an Opportunity are closed, I get some of the data of the fields of that opportunity and send these informations to another system.
But I don't know how get theses fields with APEX.
Can someone help me?
Best Regards
Rafael
Rafael,
Please utilize below code : -
trigger CriarProjeto on Opportunity (after update) {
Opportunity opty ;
opty = new Opportunity([SELECT Id, Name, Proposal_Number__c, StageName FROM Opportunity WHERE Id IN : Trigger.newMap.keyset() limit 1]);
System.debug('Name: '+ opty.Name);
System.debug('ID: '+ opty.Id);
System.debug('Proposal Number: '+ opty.Proposal_Number__c);
System.debug('Stage Name: '+ opty.StageName);
}
Thanks
All Answers
Hi Rafael,
Please do soql query to fetch fields from opportunity where isClosed equals true : - below is sample code and let me know if any questions
trigger OpportunityUpdatedTrigger on Opportunity (After Update)
{
if(Trigger.isAfter && Trigger.isUpdate)
{
List<Opportunity> opp_List = new List<Opportunity>([Select Id,Name,AccountId from Opportunity where isClosed = true]);
system.debug('aaaaa'+opp_List);
}
}
Thanks
Rajat Maheshwari
Thanks for your help, but I need get the current opportunity.
For example:
The sales rep update the opportunity and change the StageName for "Closed", After that I have to get the Id of this opportunity and get some fields of that opportunity to create a new record in another system.
Until now I can get these fields but I need especify the Opportunity Id, but I don't know how get the especific Id of that opportunity that was updated.
My code is like this:
trigger CriarProjeto on Opportunity (after update) {
Opportunity opty = new Opportunity();
opty = [SELECT Id, Name, Proposal_Number__c, StageName FROM Opportunity WHERE Id = ??????];
System.debug('Name: '+ opty.Name);
System.debug('ID: '+ opty.Id);
System.debug('Proposal Number: '+ opty.Proposal_Number__c);
System.debug('Stage Name: '+ opty.StageName);
}
Do you know how I do that?
Best Regards
Rafael.
Rafael,
Please utilize below code : -
trigger CriarProjeto on Opportunity (after update) {
Opportunity opty ;
opty = new Opportunity([SELECT Id, Name, Proposal_Number__c, StageName FROM Opportunity WHERE Id IN : Trigger.newMap.keyset() limit 1]);
System.debug('Name: '+ opty.Name);
System.debug('ID: '+ opty.Id);
System.debug('Proposal Number: '+ opty.Proposal_Number__c);
System.debug('Stage Name: '+ opty.StageName);
}
Thanks
Thanks
Thanks for your help. Now its work :)
For me I have to make some change to work, but works kkkkkk.
Thanks again for your help and atention.
Rafael,
Please let me know in case of any help :)
Email Id : rajatzmaheshwari@gmail.com
Thanks
will share your code where you are make changes in your requirements. advance thanks for your kindness
regards
krishna