You need to sign in to do that
Don't have an account?
Jim Montgomery
Getting error "variable does not exist QP.Name".
Here is my code.
trigger CopyPromotionName on Apttus_Proposal__Proposal_Line_Item__c (after insert,after update) {
Map<String,String> PromotionLookup = new Map<String,String>();
Set<String> PromotionCode = new Set<String>();
for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {
PromotionCode.add(p.apts_promo_code__c);
}
for(Promotion__c QP:
[SELECT name,promo_code__c
FROM Promotion__c
WHERE promo_code__c IN :PromotionCode]) {
PromotionLookup.put(QP.Name,QP.Promotion_Code__c);
}
for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {
if(PromotionLookup.containsKey(p.apts_Promo_Code__c)) {
p.Promotion_Name__C = PromotionLookup.get(QP.name);
}
}
trigger CopyPromotionName on Apttus_Proposal__Proposal_Line_Item__c (after insert,after update) {
Map<String,String> PromotionLookup = new Map<String,String>();
Set<String> PromotionCode = new Set<String>();
for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {
PromotionCode.add(p.apts_promo_code__c);
}
for(Promotion__c QP:
[SELECT name,promo_code__c
FROM Promotion__c
WHERE promo_code__c IN :PromotionCode]) {
PromotionLookup.put(QP.Name,QP.Promotion_Code__c);
}
for(Apttus_proposal__proposal_line_Item__c p:Trigger.new) {
if(PromotionLookup.containsKey(p.apts_Promo_Code__c)) {
p.Promotion_Name__C = PromotionLookup.get(QP.name);
}
}
If yes, here is the updated trigger for you.
I guess you need a before insert, before update trigger, not the after trigger.
All Answers
QP is not available for the line you have highlighted.
Can you replace the highlighted line in your code with the above line?
If yes, here is the updated trigger for you.
I guess you need a before insert, before update trigger, not the after trigger.
Also, check if the PromotionLookup Map is populated with right values.
Hi Jim,
Promotion_Code__c and promo_code__c are two different fields ?