You need to sign in to do that
Don't have an account?
![Jsingh Jsingh](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Check related object records on Opportunity on Opportunity Stage changed.
Hi
I have one custom object margin_calculator_... and this object have lookup of Opportunity.when we update Opportunity at a particular stage here [ stagename-'Margin cal...' () ]in this stage if there is at least one record in my custom object margin_calculator_... it should allow to update oppty at this stage or if there is no custom object records for that oppty it should not allow to update oppty at that stage.
i tried too much but not able to do in both condion.my code is working
but something is missing please help me out.
Thanks in advance.
your help will be appericiated.
jsingh
my code is as follows-
trigger OpportunityTrigger on Opportunity (before update) {
List<Margin_Calculator_Version__c> marginLst =new List<Margin_Calculator_Version__c>();
marginLst = [SELECT Id, Name, Opportunity__r.Id FROM Margin_Calculator_Version__c WHERE Opportunity__r.Id IN :Trigger.new];
for(Opportunity opp:Trigger.new){
for(Margin_Calculator_Version__c marginversion:marginLst){
Set<Id> oppId = new Set<Id>();
oppId.add(marginversion.Opportunity__r.Id);
if((oppId.Contains(opp.Id)) && (opp.StageName=='Margin Calculation'))
{
update opp;
}else{
opp.addError('Please create one record in margin version');
}
}
}
}
I have one custom object margin_calculator_... and this object have lookup of Opportunity.when we update Opportunity at a particular stage here [ stagename-'Margin cal...' () ]in this stage if there is at least one record in my custom object margin_calculator_... it should allow to update oppty at this stage or if there is no custom object records for that oppty it should not allow to update oppty at that stage.
i tried too much but not able to do in both condion.my code is working
but something is missing please help me out.
Thanks in advance.
your help will be appericiated.
jsingh
my code is as follows-
trigger OpportunityTrigger on Opportunity (before update) {
List<Margin_Calculator_Version__c> marginLst =new List<Margin_Calculator_Version__c>();
marginLst = [SELECT Id, Name, Opportunity__r.Id FROM Margin_Calculator_Version__c WHERE Opportunity__r.Id IN :Trigger.new];
for(Opportunity opp:Trigger.new){
for(Margin_Calculator_Version__c marginversion:marginLst){
Set<Id> oppId = new Set<Id>();
oppId.add(marginversion.Opportunity__r.Id);
if((oppId.Contains(opp.Id)) && (opp.StageName=='Margin Calculation'))
{
update opp;
}else{
opp.addError('Please create one record in margin version');
}
}
}
}
http://osmdroid.in/hotstar-apk-download-latest/
http://osmdroid.in/6-new-windows-10-features/
http://osmdroid.in/cyberghost-vpn-crack-mod-apk-2020-unlocked/
http://osmdroid.in/movierulz-website-download-movies/
http://osmdroid.in/gallery-vault-apk-download/
http://osmdroid.in/deezer-premium-apk-download/
http://osmdroid.in/tunnelbear-download-vpn-mod-apk-premium-unlocked/
http://osmdroid.in/az-screen-recorder-premium-mod-apk/
http://osmdroid.in/beauty-plus-apk-latest-fully-unlocked/
https://osmdroid.in/