+ Start a Discussion
chandrashekar Jangitichandrashekar Jangiti 

Need to display User's records in Junction Object based on Selected Alert country field..

Hi  Folks,

I need one trigger it is urget,
I have 3 objects like Alerts,Subscriptions,AlertSubscriptions...Subscriptions obj have Lookup User,Country picklist fields and Alerts objetct have picklist Country__c ,Name text field,

so here whenever in Alerts object selected Country field as "India" need to display India subscription user records in Junction object AlertSubscription..

Best Answer chosen by chandrashekar Jangiti
chandrashekar Jangitichandrashekar Jangiti
Myself I did and executed it currectly and also did check with Bulkification with Data Loader..working fine
for help to Others am posting code here...

trigger resultsdip on Alerts__c (after insert) {
   List<string>seltcountry = new list<string>();
    For(Alerts__c a: trigger.new){
        if(a.Country__c !=null){
    list<Subscriptions__c>sublst =[select id, name, Country__c, First_Name__c, Last_Name__c, User__c from Subscriptions__c
                                  where Country__c=:seltcountry ];
  List<AlertSubscriptions__c> listaltsub = new List<AlertSubscriptions__c>();
    for(Alerts__c a: trigger.new){
        //integer i=1;
        for(Subscriptions__c s:sublst ){            
            if(a.Country__c== s.Country__c){                
                AlertSubscriptions__c altsub = new AlertSubscriptions__c();
                altsub.Alertss__c= a.Id;
                altsub.Subscript__c = s.Id;
                altsub.User__c= s.User__c;
               // i++;
        insert listaltsub;