• tia
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 8
    Replies
 there are four objects accounts , policy(custom object) , opportunity , application(custom object). account and policy have masterdetail relationship , account and opportunity also have MD relation. and opportunity have lookup relation with application . every application must have one opportunity assigned.
there is one  field on application called 'status'. 
requiremet :when application status is 'approved by CMS' .  check if related account with opportunity have assigned active  policy?if yes , update application status to "Enrolled" .


code i have written
trigger UpdateApplicationStatusToEnrolled on vlocity_ins__Application__c (before update) {
Map <string,List<vlocity_ins__Application__c>> strMap = new Map <string,List<vlocity_ins__Application__c>>();
set<id> oppid = new set<id>();

for(vlocity_ins__Application__c app :trigger.new)
{
if(app.vlocity_ins__Status__c=='Approved by CMS')
{
oppid.add(app.id);}}




List<opportunity> oppDetails=[SELECT id, AccountId, Account.name ,Account.vlocity_ins__ActivePolicyNumber__c  
 FROM Opportunity where Account.vlocity_ins__ActivePolicyNumber__c >=1 and id IN: oppid];
 
 for(vlocity_ins__Application__c app : Trigger.new)

{
 List<vlocity_ins__Application__c> appList = strMap.containsKey(app.opportunityid) ? strMap.get(app.opportunityId) : new List<vlocity_ins__Application__c>();

                        appList.add(app);

                        strMap.put(app.opportunityId, appList);




 
}

getting error , please help 
  • June 28, 2019
  • Like
  • 0
 there are four objects accounts , policy(custom object) , opportunity , application(custom object). account and policy have masterdetail relationship , account and opportunity also have MD relation. and opportunity have lookup relation with application . every application must have one opportunity assigned.
there is one  field on application called 'status'. 
requiremet :when application status is 'approved by CMS' .  check if related account with opportunity have assigned active  policy?if yes , update application status to "Enrolled" .


code i have written
trigger UpdateApplicationStatusToEnrolled on vlocity_ins__Application__c (before update) {
Map <string,List<vlocity_ins__Application__c>> strMap = new Map <string,List<vlocity_ins__Application__c>>();
set<id> oppid = new set<id>();

for(vlocity_ins__Application__c app :trigger.new)
{
if(app.vlocity_ins__Status__c=='Approved by CMS')
{
oppid.add(app.id);}}




List<opportunity> oppDetails=[SELECT id, AccountId, Account.name ,Account.vlocity_ins__ActivePolicyNumber__c  
 FROM Opportunity where Account.vlocity_ins__ActivePolicyNumber__c >=1 and id IN: oppid];
 
 for(vlocity_ins__Application__c app : Trigger.new)

{
 List<vlocity_ins__Application__c> appList = strMap.containsKey(app.opportunityid) ? strMap.get(app.opportunityId) : new List<vlocity_ins__Application__c>();

                        appList.add(app);

                        strMap.put(app.opportunityId, appList);




 
}

getting error , please help 
  • June 28, 2019
  • Like
  • 0