Activity Forums Salesforce® Discussions How can we separate the ID's based on the record type? Reply To: How can we separate the ID's based on the record type?

  • Ajit

    Member
    August 11, 2016 at 6:53 am

    Hey Mohit,

    you will have to create number of sets equal to the record type that you have for eg: if there are two record types then create 2 sets and add values in the set on the basis of record types.

    map<id,String>mapidvsRecTypeId = new map<id,String>();

    for (Account acc : [select id , recordTypeId from Account]){

    mapidvsRecTypeId.put(acc.Id, acc.recordTypeId);

    }

    set<Id>set1 = new set<Id>();

    set<Id>set2 = new set<Id>();

    for(Id accIds : set containing account id's){

    if(mapidvsRecTypeId.get(accIds) = reocrdTypeId1 ){

    set1.add(accIds);

    }

    if(mapidvsRecTypeId.get(accIds) = reocrdTypeId2 ){

    set2.add(accIds);

    }

    }