• kiran2000
  • NEWBIE
  • 85 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 29
    Replies

I am trying to essentially re-create a custom object and then make the new copy a child to another custom object. What is the quickest way to do this ? I have looked into it on App Exchange but it appears that all of the cloning apps I've seen (iClone ; Astrea Clone) are really just about cloning records in order to maintain their related lists and such. I'm not trying to clone any records. I'm just trying to avoid re-creating the actual object from scratch.

 

Thank you very much for your help.

I am getting an error on a test class that I am not understanding: "First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [Hospital__c]" 

 

Can anyone help?

 

Here is the test class:

 

@isTest
private class TestHospitalization {
static testMethod void myUnitTest() {
     //make Contact
     Date sdate1=date.today();
     sdate1=sdate1-1;
     Date sdate2=sdate1.addMonths(3);
        Contact NewCont = new Contact (FirstName='Test', LastName='Name');
       insert NewCont;
       Account NewAcct = new Account (Name='Test');
       insert NewAcct;
       Hospitalization__c NewHosp = new Hospitalization__c (Client__c=NewCont.Id, Hospital__c=NewAcct.Id,Date_of_admission__c=sdate1);
       insert NewHosp;
       Hospitalization__c NewHosp2 = new Hospitalization__c (Client__c=NewCont.Id, Hospital__c=NewAcct.Id,Date_of_admission__c=sdate2);
       insert NewHosp2;
       NewHosp.Bed__c='1';
       update NewHosp;
       NewHosp.Date_of_admission__c=sdate2;
       update NewHosp;
   }
}

 And here is the trigger:

 

trigger CurrentHospital on Hospitalization__c (after update,after insert) {
List <Contact> UpCont=new List <Contact>();
//List <Contact> TestCont=new List <Contact>();
List <Id> TestCont=new List <Id>();
List <Contact> YesCont=new List <Contact>();

Set <Contact> MyCont=new Set <Contact>();
Map <Id, Hospitalization__c> ContHosp=new Map<Id,Hospitalization__c>();
Contact thisCont=new Contact();
//Id thisCont=new Id();
for (Hospitalization__c l : Trigger.new) {
  //thisCont=l.Client__c;
  TestCont.add(l.Client__c);
}
if(TestCont.size()>0){
    List <Hospitalization__c> HasHosp=[SELECT Client__r.Name,Client__r.Hospitalization__c,Id,Currently_in_Hospital__c FROM Hospitalization__c WHERE Client__c IN :TestCont ORDER BY Currently_in_Hospital__c ASC];
        for (Hospitalization__c b: HasHosp){
          thisCont=b.Client__r;
          if(MyCont.contains(thisCont)){
             MyCont.remove(thisCont);
      }
        if(b.Currently_in_Hospital__c==0&&thisCont.Hospitalization__c!=null){
          thisCont.Hospitalization__c=null;
          MyCont.add(thisCont);
        } else if(b.Currently_in_Hospital__c==1) {
          thisCont.Hospitalization__c=b.Id;
          MyCont.add(thisCont);
        }
        
      }
      if(MyCont.size()>0){
      UpCont.addAll(MyCont);
      }
    /*for (Integer i=0; i < TestCont.size(); i++){
        if(TestCont[i].Hospitalization__c==null){
            UpCont.add(TestCont[i]);
        }
    }*/
}

  
if(UpCont.size()>0){
update UpCont;//all contacts should be updated one way or the other
}
}

 

I was able to get Feed but not left and right panel like Photo,People,Groups,Files,Topics,Recomendations.I want to customize the chatter tab with the company look and feel on Salesforce Communities

<apex:page sidebar="false" showHeader="false">
<chatter:newsfeed/>
</apex:page>

 User-added image
Spacing between columns is not uniform.How to fix spacing

<apex:page standardController="Account">
   <apex:form >
      <apex:pageBlock title="My Block">
           <apex:pageBlockSection title="My Section" columns="4" collapsible="false">
                <apex:outputField value="{!Account.Field1__c}"/>
                <apex:outputField value="{!Account.Field2__c}"/>
                <apex:outputField value="{!Account.Field3__c}"/>
                <apex:outputField value="{!Account.Field4__c}"/>
                <apex:outputField value="{!Account.Field5__c}"/>
                <apex:outputField value="{!Account.Field6__c}"/>
                <apex:outputField value="{!Account.Field7__c}"/>
                <apex:outputField value="{!Account.Field8__c}"/>
              </apex:pageBlockSection>
         </apex:pageBlock>
  </apex:form>

I need the spell checker on visualforce page.Is there any way to acheive this.

FYI..Clients are on IE8.

I have two visualforce pages with upload functionality and checklist of items of uploaded items and items to upload in another visualforce page.Now i need to combine a upload against this checklist.Has anyone done this kind of functionality.Please help me with sample code

Sometimes it is difficult to understand the code written by some one else.Are there any tools that explain or visualize  the flow of code in visualforce and apex?

 

Thanks

Hi All,

 

 


On upload of document  to content we are creating records on custom object with a field containing the link to document and we are displaying the field on visualforce page.But the issue is some users try to delete the document from content and the link still shows up on visualforce page as the link doesn't gets deleted from the field.(custom object)

  

 

Thanks

AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROM Call2_vod__c WHERE Call_Date_vod__c >= :QuarterStartDate AND Call_Date_vod__c <= :QuarterEndDate AND Account_Type__c =:accStaticRec.Account_Type__c AND Territory_vod__c = :accStaticRec.Territory__c AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' OR Call_Type_vod__c != 'Event Only' OR Call_Type_vod__c != 'Event Detail)
AND Account_vod__c IN :accIdSet

AND Activity_Type__c <> 'Staff'
GROUP BY Account_vod__c ];

AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROM Call2_vod__c WHERE Call_Date_vod__c >= :QuarterStartDate AND Call_Date_vod__c <= :QuarterEndDate AND Account_Type__c =:accStaticRec.Account_Type__c AND Territory_vod__c = :accStaticRec.Territory__c AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' AND Call_Type_vod__c != 'Event Only' AND Call_Type_vod__c != 'Event Detail')
AND Account_vod__c IN :accIdSet

AND Activity_Type__c <> 'Staff'
GROUP BY Account_vod__c ];

 

which query is correct.Please correct me

Aggregate result returns 0 rows .I don't what is wrong with the query .Can some one help me

 

global Database.QueryLocator start(Database.BatchableContext BC){

      

        return Database.getQueryLocator('SELECT Id,Accounts__c,Calls__c,Days_Worked__c,Reaches__c,Account_Type__c,Avg_Calls__c,Quarter__c,Reach_Status__c,Territory__c,Territory_Name__c,Territory_Type__c,OwnerId,Territory_Id__c,Parent_Territory_Id__c,Grand_Parent_Territory_Id__c,Business_Days_in_Quarter__c,Date__c,Date_Type_Dashboard__c FROM Account_Statistic__c WHERE Date__c = :MonthStartDate AND Date_Type_Dashboard__c=\'Monthly\' AND Territory_Type__c = \'District\'');

    

    }

    

    global void execute(Database.BatchableContext BC, List<sObject> scope){

        List<Account_Statistic__c> accStatisticList = (List<Account_Statistic__c>)scope;

       Account_Statistic__c accStaticRec = accStatisticList[0];

       System.debug('::::::accStaticRec ::::::::'+accStaticRec );

        

        list<Id> terrIdList = new list<Id>();

        Map<Id,Id> groupIdAndTerrIdMap = new Map<Id,Id>();

        

        Map<Id,Set<Id>> terrIdAndSetOfNonTargetPractionerAccIdMap  = new Map<Id,Set<Id>>();

        Map<Id,Set<Id>> terrIdAndSetOfTargetPractionerAccIdMap  = new Map<Id,Set<Id>>();

        Map<Id,Set<Id>> terrIdAndSetOfPharmacyAccIdMap = new Map<Id,Set<Id>>();

         

        

        

        list<Territory> tlist = new list<Territory>();

        tlist = [Select t.ParentTerritoryId, t.Id From Territory t where t.ParentTerritoryId =:accStaticRec.Territory_Id__c];

        

        map<Id,list<Territory>> tmap = new map<Id,list<Territory>>{};

        

     

         Set<Id> finalaccIdSet = new Set<Id>();

         Set<Id> totalaccIdSet = new Set<id>();

         list<Id> tIdlist = new list<Id>();

         Set<Id> accIdSet = new Set<Id>();

         Set<Id> accSet = new Set<Id>();

         

         for(Territory terr:tlist){

          tIdlist.add(terr.Id);

          }        

      

           System.debug('::::tIdlist:::::'+tIdlist);

            

            for(Group groupRec : [SELECT Id,RelatedId FROM Group WHERE RelatedId In:tIdlist] ){

                groupIdAndTerrIdMap.put(groupRec.Id,groupRec.RelatedId );         

            }

         

         System.debug('::::groupIdAndTerrIdMap.keyset():::::'+groupIdAndTerrIdMap.keyset());

       

         if(groupIdAndTerrIdMap != NULL && groupIdAndTerrIdMap.size() > 0){

        

            for(AccountShare accShare : [SELECT Id,AccountId,Account.RecordTypeId,Account.RecordType.Name,Account.Target__c, UserOrGroupId FROM AccountShare WHERE (RowCause = 'Territory' OR RowCause = 'TerritoryManual') AND UserOrGroupId IN :groupIdAndTerrIdMap.keySet() AND (Account.RecordType.Name = 'Practitioner' OR Account.RecordType.Name = 'Pharmacy')] ){

                 

                 if(accShare.Account.RecordType.Name == 'Practitioner'){

                     if(accShare.Account.Target__c){

                        Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                        

                        if(!terrIdAndSetOfTargetPractionerAccIdMap.containsKey(RelatedId) )

                        terrIdAndSetOfTargetPractionerAccIdMap.put(RelatedId,new Set<Id>());

                        

                        terrIdAndSetOfTargetPractionerAccIdMap.get(RelatedId).add(accShare.AccountId);

                    }else{

                        Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                        

                        if(!terrIdAndSetOfNonTargetPractionerAccIdMap.containsKey(RelatedId) )

                        terrIdAndSetOfNonTargetPractionerAccIdMap.put(RelatedId,new Set<Id>());

                        

                        terrIdAndSetOfNonTargetPractionerAccIdMap.get(RelatedId).add(accShare.AccountId);    

                    }

                }else if(accShare.Account.RecordType.Name == 'Pharmacy'){

                    Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                    

                    if(!terrIdAndSetOfPharmacyAccIdMap.containsKey(RelatedId) )

                    terrIdAndSetOfPharmacyAccIdMap.put(RelatedId,new Set<Id>());

                    

                    terrIdAndSetOfPharmacyAccIdMap.get(RelatedId).add(accShare.AccountId);    

                }

                       

            }

        } 

       

       for(Territory terr:tlist){

       

        if(accStaticRec.Account_Type__c == 'Target'){

            accIdSet = terrIdAndSetOfTargetPractionerAccIdMap.get(terr.Id);

        }else if(accStaticRec.Account_Type__c == 'Non-Target'){

            accIdSet = terrIdAndSetOfNonTargetPractionerAccIdMap.get(terr.Id);

        }else if(accStaticRec.Account_Type__c == 'Pharmacy'){

            accIdSet = terrIdAndSetOfPharmacyAccIdMap.get(terr.Id);

        }

    

        

        System.debug('::::accIdSet:::::'+accIdSet);

        

      

        

        if(accIdSet != NULL && accIdSet.size() > 0){

             System.debug('::::accIdSet:::::'+accIdSet);

             System.debug('::::terr.Id:::::'+terr.Id);

             String tId = Id.valueOf(terr.Id);

             System.debug('::::tId::::'+tId);

            AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROM Call2_vod__c WHERE Call_Date_vod__c >= :MonthStartDate  AND Call_Date_vod__c <= :MonthEndDate  AND Account_Type__c =:accStaticRec.Account_Type__c 

                                                        AND Territory_vod__c =:tId AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' OR Call_Type_vod__c != 'Event Only' OR Call_Type_vod__c != 'Event Detail')

                                                        AND Account_vod__c IN :accIdSet  

                                                   

                                                        AND Activity_Type__c <> 'Staff'

                                                        GROUP BY Account_vod__c ];

            

            System.debug('::::groupedResultCall:::::'+groupedResultCall);

            Map<Id,Integer> AccIdAndCountOfCallMap = new Map<Id,Integer>();

            Integer totalCallsCount = 0;

            

            for (AggregateResult ar : groupedResultCall)  {

                String accId  = String.ValueOf(ar.get('Account_vod__c'));

                System.debug('::::accId:::::'+accId);

                accSet.add(Id.valueOf(accId));

                System.debug('::::accSet:::::'+accSet);

                finalaccIdSet.addAll(accSet);

                System.debug('::::finalaccIdSet:::::'+finalaccIdSet);

              }

             System.debug('::::totalaccIdSet:::::'+totalaccIdSet); 

             totalaccIdSet.addAll(accIdSet); 

             System.debug('::::finalaccIdSet:::::'+finalaccIdSet);

             System.debug('::::totalaccIdSet:::::'+totalaccIdSet); 

           }

           System.debug('::::finalaccIdSet:::::'+finalaccIdSet.size());

           System.debug('::::totalaccIdSet:::::'+totalaccIdSet.size());

         }

          System.debug('::::finalaccIdSet:::::'+finalaccIdSet.size());

          System.debug('::::totalaccIdSet:::::'+totalaccIdSet.size());

          

        if(accStaticRec.Reach_Status__c == 'Reached'){

            accStaticRec.Accounts__c = finalaccIdSet.size(); 

         }else if(accStaticRec.Reach_Status__c == 'Not Reached'){

                if(finalaccIdSet.size() == totalaccIdSet.size()){

                    accStaticRec.Accounts__c = 0;

                }else{

                    accStaticRec.Accounts__c = totalaccIdSet.size() - finalaccIdSet.size();

                }

             }

       

          if(accStaticRec != NULL) {

          update accStaticRec;

           

           System.debug(':::::accStaticRec::::::::::'+accStaticRec); 

       

            

         

                    }

                    

                }

            }

            System.debug(':::::FinalMap:::::::'+FinalMap);         

       } 

      

 global void execute(Database.BatchableContext BC, List<sObject> scope){

        List<Account_Statistic__c> accStatisticList = (List<Account_Statistic__c>)scope;

       Account_Statistic__c accStaticRec = accStatisticList[0];

       System.debug('::::::accStaticRec ::::::::'+accStaticRec );

        

        list<Id> terrIdList = new list<Id>();

        Map<Id,Id> groupIdAndTerrIdMap = new Map<Id,Id>();

        

        Map<Id,Set<Id>> terrIdAndSetOfNonTargetPractionerAccIdMap  = new Map<Id,Set<Id>>();

        Map<Id,Set<Id>> terrIdAndSetOfTargetPractionerAccIdMap  = new Map<Id,Set<Id>>();

        Map<Id,Set<Id>> terrIdAndSetOfPharmacyAccIdMap = new Map<Id,Set<Id>>();

         

        

        

        list<Territory> tlist = new list<Territory>();

        tlist = [Select t.ParentTerritoryId, t.Id From Territory t where t.ParentTerritoryId =:accStaticRec.Territory_Id__c];

        

        map<Id,list<Territory>> tmap = new map<Id,list<Territory>>{};

        

     

         Set<Id> finalaccIdSet = new Set<Id>();

         Set<Id> totalaccIdSet = new Set<id>();        

      

         for(Territory terr:tlist){

            

            for(Group groupRec : [SELECT Id,RelatedId FROM Group WHERE RelatedId =:terr.Id] ){

                groupIdAndTerrIdMap.put(groupRec.Id,groupRec.RelatedId );         

            }

       

         if(groupIdAndTerrIdMap != NULL && groupIdAndTerrIdMap.size() > 0){

        

            for(AccountShare accShare : [SELECT Id,AccountId,Account.RecordTypeId,Account.RecordType.Name,Account.Target__c, UserOrGroupId FROM AccountShare WHERE (RowCause = 'Territory' OR RowCause = 'TerritoryManual') AND UserOrGroupId IN :groupIdAndTerrIdMap.keySet() AND (Account.RecordType.Name = 'Practitioner' OR Account.RecordType.Name = 'Pharmacy')] ){

                 

                 if(accShare.Account.RecordType.Name == 'Practitioner'){

                     if(accShare.Account.Target__c){

                        Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                        

                        if(!terrIdAndSetOfTargetPractionerAccIdMap.containsKey(RelatedId) )

                        terrIdAndSetOfTargetPractionerAccIdMap.put(RelatedId,new Set<Id>());

                        

                        terrIdAndSetOfTargetPractionerAccIdMap.get(RelatedId).add(accShare.AccountId);

                    }else{

                        Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                        

                        if(!terrIdAndSetOfNonTargetPractionerAccIdMap.containsKey(RelatedId) )

                        terrIdAndSetOfNonTargetPractionerAccIdMap.put(RelatedId,new Set<Id>());

                        

                        terrIdAndSetOfNonTargetPractionerAccIdMap.get(RelatedId).add(accShare.AccountId);    

                    }

                }else if(accShare.Account.RecordType.Name == 'Pharmacy'){

                    Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                    

                    if(!terrIdAndSetOfPharmacyAccIdMap.containsKey(RelatedId) )

                    terrIdAndSetOfPharmacyAccIdMap.put(RelatedId,new Set<Id>());

                    

                    terrIdAndSetOfPharmacyAccIdMap.get(RelatedId).add(accShare.AccountId);    

                }

                       

            }

        } 

       

        Set<Id> accIdSet = new Set<Id>();

        Set<Id> accSet = new Set<Id>();

        if(accStaticRec.Account_Type__c == 'Target'){

            accIdSet = terrIdAndSetOfTargetPractionerAccIdMap.get(accStaticRec.Territory_Id__c);

        }else if(accStaticRec.Account_Type__c == 'Non-Target'){

            accIdSet = terrIdAndSetOfNonTargetPractionerAccIdMap.get(accStaticRec.Territory_Id__c);

        }else if(accStaticRec.Account_Type__c == 'Pharmacy'){

            accIdSet = terrIdAndSetOfPharmacyAccIdMap.get(accStaticRec.Territory_Id__c);

        }

        

        if(accIdSet != NULL && accIdSet.size() > 0){

            

            AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROM Call2_vod__c WHERE Call_Date_vod__c >= :MonthStartDate  AND Call_Date_vod__c <= :MonthEndDate  AND Account_Type__c =:accStaticRec.Account_Type__c 

                                                        AND Territory_vod__c =:terr.Id AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' OR Call_Type_vod__c != 'Event Only' OR Call_Type_vod__c != 'Event Detail')

                                                        AND Account_vod__c IN :accIdSet  

                                                        //PS added 7.11.2013

                                                        AND Activity_Type__c <> 'Staff'

                                                        GROUP BY Account_vod__c ];

            

            System.debug('::::groupedResultCall:::::'+groupedResultCall);

            Map<Id,Integer> AccIdAndCountOfCallMap = new Map<Id,Integer>();

            Integer totalCallsCount = 0;

            

            for (AggregateResult ar : groupedResultCall)  {

                String accId  = String.ValueOf(ar.get('Account_vod__c'));

                accSet.add(Id.valueOf(accId));

                finalaccIdSet.addAll(accSet);

              }

             totalaccIdSet.addAll(accIdSet); 

           }

           System.debug('::::finalaccIdSet:::::'+finalaccIdSet.size());

           System.debug('::::totalaccIdSet:::::'+totalaccIdSet.size());

         }

          System.debug('::::finalaccIdSet:::::'+finalaccIdSet.size());

          System.debug('::::totalaccIdSet:::::'+totalaccIdSet.size());

          

        if(accStaticRec.Reach_Status__c == 'Reached'){

            accStaticRec.Accounts__c = finalaccIdSet.size(); 

         }else if(accStaticRec.Reach_Status__c == 'Not Reached'){

                if(finalaccIdSet.size() == totalaccIdSet.size()){

                    accStaticRec.Accounts__c = 0;

                }else{

                    accStaticRec.Accounts__c = totalaccIdSet.size() - finalaccIdSet.size();

                }

             }

       

          if(accStaticRec != NULL) {

          update accStaticRec;

           

           System.debug(':::::accStaticRec::::::::::'+accStaticRec); 

       

            

            //----------------------Processing Map Formation---------------------------------------------

           

 

            if(!FinalMap.containsKey(accStaticRec.Grand_Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c)){

            

                Map<String,Map<String,Decimal>> DistrictMap = new Map<String,Map<String,Decimal>>();

                String mapKey = accStaticRec.Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c;

                DistrictMap.put(mapKey,new Map<String,Decimal>());

                DistrictMap.get(mapKey).put('#Accounts',accStaticRec.Accounts__c);

                

                

                Map<String,Map<String,Map<String,Decimal>>> RegionMap = new Map<String,Map<String,Map<String,Decimal>>>();

                RegionMap.put(accStaticRec.Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c,DistrictMap);

                

                

                FinalMap.put(accStaticRec.Grand_Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c,RegionMap);

              

                

            }else {

                Map<String,Map<String,Map<String,Decimal>>> RegionFinalMap = new Map<String,Map<String,Map<String,Decimal>>>();

                RegionFinalMap = FinalMap.get(accStaticRec.Grand_Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c);

                if(!RegionFinalMap.containsKey(accStaticRec.Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c)){

                    

                    Map<String,Map<String,Decimal>> DistrictMap = new Map<String,Map<String,Decimal>>();

                

                    String mapKey3 = accStaticRec.Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c;

                    DistrictMap.put(mapKey3,new Map<String,Decimal>());

                

                    DistrictMap.get(mapKey3).put('#Accounts',accStaticRec.Accounts__c);

                    

                    

                   // Map<String,Map<String,Map<String,Decimal>>> RegionFinalMap = new Map<String,Map<String,Map<String,Decimal>>>();

                    RegionFinalMap.put(accStaticRec.Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c,DistrictMap);

                    

                   FinalMap.put(accStaticRec.Grand_Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c,RegionFinalMap);

                  

                    

                }else{

                  

                        Map<String,Map<String,Decimal>> DistrictFinalMap = RegionFinalMap.get(accStaticRec.Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c);

                        

                        String mapKey1 = accStaticRec.Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c;

                        DistrictFinalMap.put(mapKey1,new Map<String,Decimal>());

                        DistrictFinalMap.get(mapKey1).put('#Accounts',accStaticRec.Accounts__c);

                        

                        RegionFinalMap.put(accStaticRec.Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c,DistrictFinalMap);

                        FinalMap.put(accStaticRec.Grand_Parent_Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c,RegionFinalMap);

               

                    }

                    

                }

            }

            System.debug(':::::FinalMap:::::::'+FinalMap);         

       } 

Also i am getting  error "Save error: Invalid bind expression type of SOBJECT:Territory for column of type String"

 

against the highlighted soql .(Territory_vod__c in: relatedIdlist)

 

list<Id> terrIdList = new list<Id>();

        Map<Id,Id> groupIdAndTerrIdMap = new Map<Id,Id>();

        

        Map<Id,Set<Id>> terrIdAndSetOfNonTargetPractionerAccIdMap  = new Map<Id,Set<Id>>();

        Map<Id,Set<Id>> terrIdAndSetOfTargetPractionerAccIdMap  = new Map<Id,Set<Id>>();

        Map<Id,Set<Id>> terrIdAndSetOfPharmacyAccIdMap = new Map<Id,Set<Id>>();

         Set<Id> finalaccIdSet = new Set<Id>();

        

         for(Account_Statistic__c accStatic : districtAccList){

           

           Id tID = Id.valueOf(accStatic.Territory_Id__c);

           terrIdList.add(tId); 

        }

        

        list<Territory> tlist = new list<Territory>();

        tlist = [Select t.ParentTerritoryId, t.Id From Territory t where t.ParentTerritoryId in:terrIdList];

        

        map<Id,list<Territory>> tmap = new map<Id,list<Territory>>{};

        

        for(Territory t:tlist){

          if(tmap.containsKey(t.ParentTerritoryId)){

          tmap.get(t.ParentTerritoryId).add(t);

          }else{

          list<Territory> plist = new list<Territory>();

          plist.add(t);

          tmap.put(t.ParentTerritoryId,plist);

          }

        }

        

        list<Territory>relatedIdlist= new list<Territory>();

        for(Account_Statistic__c accStaticRec:districtAccList)

        {         

         relatedIdlist = tmap.get(accStaticRec.Territory_Id__c);

         if(relatedIdlist != NULL && relatedIdlist.size() > 0){

            for(Group groupRec : [SELECT Id,RelatedId FROM Group WHERE RelatedId IN :relatedIdlist] ){

                groupIdAndTerrIdMap.put(groupRec.Id,groupRec.RelatedId );         

            }

         }

        

         if(groupIdAndTerrIdMap != NULL && groupIdAndTerrIdMap.size() > 0){

        

            for(AccountShare accShare : [SELECT Id,AccountId,Account.RecordTypeId,Account.RecordType.Name,Account.Target__c, UserOrGroupId FROM AccountShare WHERE (RowCause = 'Territory' OR RowCause = 'TerritoryManual') AND UserOrGroupId IN :groupIdAndTerrIdMap.keySet() AND (Account.RecordType.Name = 'Practitioner' OR Account.RecordType.Name = 'Pharmacy')] ){

                 

                 if(accShare.Account.RecordType.Name == 'Practitioner'){

                     if(accShare.Account.Target__c){

                        Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                        

                        if(!terrIdAndSetOfTargetPractionerAccIdMap.containsKey(RelatedId) )

                        terrIdAndSetOfTargetPractionerAccIdMap.put(RelatedId,new Set<Id>());

                        

                        terrIdAndSetOfTargetPractionerAccIdMap.get(RelatedId).add(accShare.AccountId);

                    }else{

                        Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                        

                        if(!terrIdAndSetOfNonTargetPractionerAccIdMap.containsKey(RelatedId) )

                        terrIdAndSetOfNonTargetPractionerAccIdMap.put(RelatedId,new Set<Id>());

                        

                        terrIdAndSetOfNonTargetPractionerAccIdMap.get(RelatedId).add(accShare.AccountId);    

                    }

                }else if(accShare.Account.RecordType.Name == 'Pharmacy'){

                    Id RelatedId = groupIdAndTerrIdMap.get(accShare.UserOrGroupId );

                    

                    if(!terrIdAndSetOfPharmacyAccIdMap.containsKey(RelatedId) )

                    terrIdAndSetOfPharmacyAccIdMap.put(RelatedId,new Set<Id>());

                    

                    terrIdAndSetOfPharmacyAccIdMap.get(RelatedId).add(accShare.AccountId);    

                }

                       

            }

        } 

       

        Set<Id> accIdSet = new Set<Id>();

        

        if(accStaticRec.Account_Type__c == 'Target'){

            accIdSet = terrIdAndSetOfTargetPractionerAccIdMap.get(accStaticRec.Territory_Id__c);

        }else if(accStaticRec.Account_Type__c == 'Non-Target'){

            accIdSet = terrIdAndSetOfNonTargetPractionerAccIdMap.get(accStaticRec.Territory_Id__c);

        }else if(accStaticRec.Account_Type__c == 'Pharmacy'){

            accIdSet = terrIdAndSetOfPharmacyAccIdMap.get(accStaticRec.Territory_Id__c);

        }

        

        if(accIdSet != NULL && accIdSet.size() > 0){

            AggregateResult[] groupedResultCall = [SELECT Account_vod__c,count(Id) FROMCall2_vod__cWHERE Call_Date_vod__c >= :MonthStartDate  AND Call_Date_vod__c <= :MonthEndDate  AND Account_Type__c =:accStaticRec.Account_Type__c 

                                                        AND Territory_vod__c in: relatedIdlist AND Status_vod__c = 'Submitted_vod' AND (Call_Type_vod__c != 'Call Only' OR Call_Type_vod__c != 'Event Only' OR Call_Type_vod__c != 'Event Detail')

                                                        AND Account_vod__c IN :accIdSet  

                                                       

                                                        AND Activity_Type__c <> 'Staff'

                                                        GROUP BY Account_vod__c ];

            

            System.debug('::::groupedResultCall:::::'+groupedResultCall);

            Map<Id,Integer> AccIdAndCountOfCallMap = new Map<Id,Integer>();

            Integer totalCallsCount = 0;

            

            for (AggregateResult ar : groupedResultCall)  {

                String accId  = String.ValueOf(ar.get('Account_vod__c'));

                finalaccIdSet.add(Id.valueOf(accId));

              }

           }

              

         if(accStaticRec.Reach_Status__c == 'Reached'){

            accStaticRec.Accounts__c = finalaccIdSet.size(); 

         }else if(accStaticRec.Reach_Status__c == 'Not Reached'){

                if(finalaccIdSet.size() == accIdSet.size()){

                    accStaticRec.Accounts__c = 0;

                }else{

                    accStaticRec.Accounts__c = accIdSet.size() - finalaccIdSet.size();

                }

         accStaticListUpdate.add(accStaticRec);

            String mapKey = accStaticRec.Territory_Id__c+accStaticRec.Account_Type__c+accStaticRec.Reach_Status__c;

            ProcessedDistrictMap.put(mapKey,new Map<String,Decimal>());

            ProcessedDistrictMap.get(mapKey).put('#Accounts',accStaticRec.Accounts__c);

         }

        } 

Hi,

 

 I need to convert set of ids to string.

 

Set<id> accIdSet = new Set<Id>();

 

I need to contcatinate the string to another string.

 

after processing i need to retreive the set of ids.

 

Can someone show me some example around this.

 

 

Thanks

Hi,

 

  I want to display the number of accounts per territory on a record.Accounts can be tied to more than1 territory.So please share some sample code to do this.

 

Thanks

Hi All,

 

  The below batch updates account statistics records with the values of  # accounts,# calls ,# days worked on Teritorry type = Territory,Territory Type = District, Territory Type= Region and Territory Type = Nation from Call object(Call2_vod__c)

 

Nation

  |

  Region

    |

    District

        |

       Territory A

       Territory B

       Territory C

......

 

 

Values(#Accounts,#Calls,#days Worked) on Territory rollups to District level and values on District level rollups to Region and similarly to Nation level.

 

The issue i have is # Accounts on Disctrict level,Region level and Nation Level.

 

Lets say Territory A has Account A,Account B

                Territory B has Account B,Account C,Account D

                Territory C has Account A,Account B,Account C

 

So # Accounts on Territory A is 2

                                 Territory B is 3

                                 Territory C is 3

 

which displays correctly on Account Satistics records for Territory level

 

But the issue on District level ..the value of # Accounts is  2+3+3 = 8  (rollups up value )

 

 I neeed to get unique set accounts which  should be # Accounts = Account A+Account B+Account C +Account D = 4

 

So i should get # accounts on Distrcit level should be 4 but right now it displays 8 .

 

Can some one help me in fixing the below batch apex.

 

 

I have to post in different sections as it exceeded 20,000 char.Sorry about this

 

 

 

Hi All,

 

I have a custom objects called Deal__c ,Document_Type__c,Uploaded_Documents__c . 

 

Uploaded_Documents__c has a lookup relationship to Deal__c 

 

Uploaded_Documents__c  has  a lookup relationship to Document_Type__c

 

Content (Standard object) has lookup to Deal__c

 

Content (standard object) has lookup to Document_Type__c.

 

 

There a visualforce page(custom link from Deal__c)  where they upload the document.There is another visualforce page basicially has the checklist of documents(document type) (custom link from Deal__c) which shows the list of  documents that got uploaded and also the list of documents which needs to be uploaded to close the deal

 

On insert of document there is trigger on Deal__c which creates Uploaded_Documents__c record for each insert of the record.

 

The issue is  if there is any update of document type  like deleting the document type (means removing from the document checklist) will remove the correspoding link to 2nd visualforce page.

 

We don't want to affect the deals that already has some document uploaded.we just want to affect the deals for newly created ones.

 

I need some help on how to handle document type think just like checklist of document types which gets changed frequently.

 

 

 

Hi All,

  

    I am getting OutOfmemory:JavaHeap Size error on mac book while creating new project in eclipse.I increased the heap size to 1024m in eclipse.ini but still getting error.can any one help me.

 

Thanks,

Kiran

Hi All,

 

I need drag and drop functionality in visualforce.can someone help me .

 

 

Thanks,

Kiran

HI,

 

How to acheive drag and drop files in visualforce page

 

Thanks

Hi All,

 

 How to acheive drag and drop files within visualforce page.

 

Thanks

Spacing between columns is not uniform.How to fix spacing

<apex:page standardController="Account">
   <apex:form >
      <apex:pageBlock title="My Block">
           <apex:pageBlockSection title="My Section" columns="4" collapsible="false">
                <apex:outputField value="{!Account.Field1__c}"/>
                <apex:outputField value="{!Account.Field2__c}"/>
                <apex:outputField value="{!Account.Field3__c}"/>
                <apex:outputField value="{!Account.Field4__c}"/>
                <apex:outputField value="{!Account.Field5__c}"/>
                <apex:outputField value="{!Account.Field6__c}"/>
                <apex:outputField value="{!Account.Field7__c}"/>
                <apex:outputField value="{!Account.Field8__c}"/>
              </apex:pageBlockSection>
         </apex:pageBlock>
  </apex:form>

Hi All,

 

 


On upload of document  to content we are creating records on custom object with a field containing the link to document and we are displaying the field on visualforce page.But the issue is some users try to delete the document from content and the link still shows up on visualforce page as the link doesn't gets deleted from the field.(custom object)

  

 

Thanks

Hi All,

 

  The below batch updates account statistics records with the values of  # accounts,# calls ,# days worked on Teritorry type = Territory,Territory Type = District, Territory Type= Region and Territory Type = Nation from Call object(Call2_vod__c)

 

Nation

  |

  Region

    |

    District

        |

       Territory A

       Territory B

       Territory C

......

 

 

Values(#Accounts,#Calls,#days Worked) on Territory rollups to District level and values on District level rollups to Region and similarly to Nation level.

 

The issue i have is # Accounts on Disctrict level,Region level and Nation Level.

 

Lets say Territory A has Account A,Account B

                Territory B has Account B,Account C,Account D

                Territory C has Account A,Account B,Account C

 

So # Accounts on Territory A is 2

                                 Territory B is 3

                                 Territory C is 3

 

which displays correctly on Account Satistics records for Territory level

 

But the issue on District level ..the value of # Accounts is  2+3+3 = 8  (rollups up value )

 

 I neeed to get unique set accounts which  should be # Accounts = Account A+Account B+Account C +Account D = 4

 

So i should get # accounts on Distrcit level should be 4 but right now it displays 8 .

 

Can some one help me in fixing the below batch apex.

 

 

I have to post in different sections as it exceeded 20,000 char.Sorry about this

 

 

 

Hi All,

  

    I am getting OutOfmemory:JavaHeap Size error on mac book while creating new project in eclipse.I increased the heap size to 1024m in eclipse.ini but still getting error.can any one help me.

 

Thanks,

Kiran

HI,

 

How to acheive drag and drop files in visualforce page

 

Thanks

Hi All,

 

 How to acheive drag and drop files within visualforce page.

 

Thanks

 

Does whitespace matter between the ELSE and IF keywords?  For example are the two code snips below the same logic wise?

 

if(condition){

}
else if(condition){

}
else{

}

 

if(condition){

}
else 
    if(condition){

}
else{

}

 

Hi,

I have created a WSDL from an existing APEX class. How can I designate certain fields in the WSDL as mandatory ("minoccurs = 1")?

I am trying to essentially re-create a custom object and then make the new copy a child to another custom object. What is the quickest way to do this ? I have looked into it on App Exchange but it appears that all of the cloning apps I've seen (iClone ; Astrea Clone) are really just about cloning records in order to maintain their related lists and such. I'm not trying to clone any records. I'm just trying to avoid re-creating the actual object from scratch.

 

Thank you very much for your help.

how to copy the data from one sandbox to another sandbox  within the organization ?

what are the steps involved ?

 

Hi All,

 

 I am trying to clean up data on one of our custom object.So there are many duplicates associated with that.So i need to remove the duplicates and reassign the related list records to the original one.There is lookup relationship between two objects.How to identify any related records on custom object.If it is a Master-Detail relationship i could have done rollup summary on it and could easily identify any related list records or not  but it has lookup relation ship between two objects.Please help me.

 

 

Thanks

Hi,

I am trying to export the data to excel sheet from apex class.

i know that we can do the export from vocabularies page.but i want that export to be done from apex class.

how can i achieve this?Please help me out.

  • July 17, 2013
  • Like
  • 0

Sales Team sends out an original document pack w/ 6 documents. Over time one of the docs gets modified and through SF Version control, they update the original Document. The question is: does the original link and docs included in the original content pack see this reflection and change.

Hi,

 

    I am calling the Chatter Standard page from a VF Page but when I am getting that page as display I dont want to show any headers in that page. Please let me know how I can acheive that. 

 

The code which I am using is as below : 

 

<apex:page sidebar="false" showHeader="false">
<script>
oNewDoc = window.open('https://ap1.salesforce.com/_ui/core/chatter/ui/ChatterPage','_self');
</script>
</apex:page>

 

When I load this VF page I dont want to display the header of the standard SFDC page. Can anyone please suggest me how i can proceed with this.

 

Thanks,

Karthik