• swapna muthiyalu
  • NEWBIE
  • 100 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 25
    Replies
set<string>mEmpId = new set<string>();
map<string,id> MEmpIds = new map<string,id>(); 
list<Contact> con = [SELECT id,eid,AccountId, from Contact where (eid__c IN :mEmpId);
  for(Contact c : con)
        {
             if(mEmpId.contains(m.eid__c) 
            {
                MEmpIds.put(m.eid__c, c.Id);
            }
        }

how to use map of map for map<id,map<string,id>> MEmpIds = new map<string,id>();  and validate the put is from respective account id
i have this query, select id, accountid, seccon__r.accountid from contact..
now how to write the same query to check if accountid is equal to  seccon__r.accountid ?
set<string>mEmpId = new set<string>();
set<string>hEmpId = new set<string>();

if (mEmpId .size() == 0 && hEmpId.size() > 0){

list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];

} else if(hEmpId.size() == 0 && mEmpId.size() > 0){

list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];

}else if (mEmpId.size() > 0 && hEmpId.size() > 0)


{list<contact>listcon = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexm__c = ‘yes’) or (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];} ;

The requirement is i have account say Burlington textiles, i have many contacts and they have empid__c. similar way there are many accounts and related contacts with empid__c. but the empid__c may be same for many contacts. now i want to validate that the reportsto field in contact has the same contact which belongs to the same account,which is not validated in the above code. for example i have jack as contact who belongs to the account burligton, has Peter in the report to field, now i have to validate that peter also belongs to the burlington account.
set<string>mEmpId = new set<string>();
set<string>hEmpId = new set<string>();
if (mEmpId .size() == 0){
list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];
} else if(hEmpId.size() == 0){
list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];
}else if (mEmpId.size() > 0 && hEmpId.size() > 0)
{list<contact>listcon = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexm__c = ‘yes’) or (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];} ;
set<string>mEmpId = new set<string>();
set<string>hEmpId = new set<string>();
 
list<contact>listcon = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexm__c = ‘yes’) or (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ]

now i want to check if mEmpId and hEmpId are blank and if it is blank i have to run this query? how to check the set is empty?
 
set<string>mEmpId = new set<string>();
map<string,id> MEmpIds = new map<string,id>(); 
list<Contact> con = [SELECT id,eid,AccountId, from Contact where (eid__c IN :mEmpId);
  for(Contact c : con)
        {
             if(mEmpId.contains(m.eid__c) 
            {
                MEmpIds.put(m.eid__c, c.Id);
            }
        }

how to use map of map for map<id,map<string,id>> MEmpIds = new map<string,id>();  and validate the put is from respective account id
i have this query, select id, accountid, seccon__r.accountid from contact..
now how to write the same query to check if accountid is equal to  seccon__r.accountid ?
set<string>mEmpId = new set<string>();
set<string>hEmpId = new set<string>();

if (mEmpId .size() == 0 && hEmpId.size() > 0){

list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];

} else if(hEmpId.size() == 0 && mEmpId.size() > 0){

list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];

}else if (mEmpId.size() > 0 && hEmpId.size() > 0)


{list<contact>listcon = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexm__c = ‘yes’) or (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];} ;

The requirement is i have account say Burlington textiles, i have many contacts and they have empid__c. similar way there are many accounts and related contacts with empid__c. but the empid__c may be same for many contacts. now i want to validate that the reportsto field in contact has the same contact which belongs to the same account,which is not validated in the above code. for example i have jack as contact who belongs to the account burligton, has Peter in the report to field, now i have to validate that peter also belongs to the burlington account.
set<string>mEmpId = new set<string>();
set<string>hEmpId = new set<string>();
if (mEmpId .size() == 0){
list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];
} else if(hEmpId.size() == 0){
list<Contact> mgrHrRecs = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];
}else if (mEmpId.size() > 0 && hEmpId.size() > 0)
{list<contact>listcon = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexm__c = ‘yes’) or (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ];} ;
set<string>mEmpId = new set<string>();
set<string>hEmpId = new set<string>();
 
list<contact>listcon = [select id, empid__c,AccountId, Type__c from contact where (empid__c IN : mEmpId and AccountId IN :accountids and indexm__c = ‘yes’) or (empid__c IN : hEmpId and AccountId IN :accountids and indexh__c = ‘yes’) ]

now i want to check if mEmpId and hEmpId are blank and if it is blank i have to run this query? how to check the set is empty?