• er.rajhanschaubey
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 0
    Replies
public with sharing class updateAssetController {

    private list<ASSETS__c> asset;
    private list<AUDIT__c> audit;
   private list<AggregateResult> aggResult;
    private Integer Total;
    private String str; 
    private list<answerData> answer;
    private map<String,list<answerData>> ansData ;
    private map<String,Map<String,list<answerData>>> containsAllData ;
    private Integer Totalcount=0;
    private list<answerData>  filAns;
 
   
    public updateAssetController(){
  
       
    }
   
    
    public void allRecord(){
    
       
        asset = [Select id,name from ASSETS__c];
       
        list<String> nameList = new list<String>{'MAKE__c','COUNTRY__c'} ;
           
        ansData = new Map<String,List<answerData>>();
       
        for(String fieldName :nameList){
        
         String query = 'SELECT count(Id) myCount,'+fieldName+',ASSETS__c ';
                query+=  ' FROM AUDIT__c  GROUP BY '+fieldName+',ASSETS__c';
        
         aggResult = Database.query(query);
         
          for(AggregateResult ar:aggResult){
          
             String question;
             Total =  (Integer)ar.get('myCount');
             str = (String)ar.get(fieldName);
           
             question = fieldName.replaceAll('__c','');
            
             if(!ansData.containsKey(question)){
               
                 answer =new List<answerData>();
                 answer.add(new answerData(Total,str,(String)ar.get('ASSETS__c')));
                 ansData.put((question),answer);
             }
             else{
             
                 list<answerData> existingvalue = ansData.get((question));
                 existingvalue.add(new answerData(Total,str,(String)ar.get('ASSETS__c')));
             }
          }
        }
       
        containsAllData = new Map<String,Map<String,List<answerData>>>();
               
        for(ASSETS__c au :asset){
        
         map<String,list<answerData>> filterData = new map<String,list<answerData>>();
        
            for (String s : ansData.keySet()){
            
                list<answerData>  filAns =new list<answerData>();
               
                for(answerData anData : ansData.get(s)){
                
                 if(anData.Auid == au.id){
                 
                  filAns.add(new answerData(anData.a,anData.result,anData.Auid));                        
                        filterData.put(s,filAns);
                 }
                }
            }
            containsAllData.put(au.id,filterData);
        }
       
        Set<ASSETS__c> allAsset =  new Set<ASSETS__c>();
        map<String,List<answerData>> relatedRecord = new map<String,list<answerdata>>();
       
        for (String str : containsAllData.keySet()){
        
            ASSETS__c a = new ASSETS__c(id=str);
            relatedRecord = containsAllData.get(str);
            for(String assign: relatedRecord.keyset()){
            
             if(Assign=='MAKE'){
                 Integer firstInt =0;
                    Integer second =0;
                    String firstValue;
                    String secondValue;
                    Totalcount=0;
                   
                    for(answerData st:relatedRecord.get(assign)){
                    
                     Totalcount +=st.a;
                        if(firstInt == 0|| firstInt<st.a){
                         if(st.result != null && st.a> firstInt){
                                firstInt = st.a;
                                firstValue = st.result;
                            }else if(st.result == null && st.a> firstInt){
                                second =st.a;
                                secondValue =st.result;
                            }
                           
                        }
                    }
                    if(firstInt > 1){
                     a.MAKE__c = firstValue;
                    }
                    else{
                     a.MAKE__c = secondValue;
                    }
             }
               
                else if(Assign=='COUNTRY'){
                 Integer firstInt =0;
                    Integer second =0;
                    String firstValue;
                    String secondValue;
                    Totalcount=0;
                   
                    for(answerData st:relatedRecord.get(assign)){
                    
                        Totalcount +=st.a;
                        if(firstInt == 0|| firstInt<st.a){
                         if(st.result != null && st.a> firstInt){
                                firstInt = st.a;
                                firstValue = st.result;
                            }else if(st.result == null && st.a> firstInt){
                                second =st.a;
                                secondValue =st.result;
                         }
                        }
                    }
                          
                    if(firstInt > 1){
                     a.COUNTRY__c = firstValue;
                    }
                    else{
                     a.COUNTRY__c = secondValue;
                    }
                }
               
            }
            allAsset.add(a);
        }
        list<ASSETS__c> assetRecord =new list<ASSETS__c>();
        assetRecord.addALL(allAsset);
      
       
        update assetRecord;
     
        
    }  
   
    public class answerData {
        
        public Integer a;
        public String Result; 
        private String Auid;    
      
        public answerData(Integer a, String Result,String AssetId) {
            this.a =a;
            this.Result=Result;
            auid = AssetId;
        }
    }
  
}
I am trying to build a hybrid application on mobile using salesforce application. I want to upload images to s3 also. If network is not available all images and data will be saved in offline cache and once n/w available images should sync with aws 3 and data with salesforce. Any idea how to move ahead on this? will it be possible with Salesforce hybrid app or not?
we are building a force.com site with communities and we are using OEM license for it. now my question is how will we be able to assign this license to the users of our partner companies when they will register from front head. i mean to say i cant identify this license  in the user table.

we are building a force.com site with communities and we are using OEM license for it. now my question is how will we be able to assign this license to the users of our partner companies when they will register from front head. i mean to say i cant identify this license  in the user table.