• mohan s 37
  • NEWBIE
  • 120 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 19
    Replies
Hi,
How do we @JsonAccess annotation for deserializing the json. Can anyone give example code. I want to deseralize below json
{"Details":[{"FirstName":"Name","LastName":"lastname","Email":"sample@mail.com"},{"FirstName":"Name","LastName":"lastname","Email":"sample@mail.com"}]
Thanks,
Mohan
Hi,
I am testing the mobile version of my salesforce lightning apps using the chrome version but It not displaying apps instead, its showing all the tabs in the org. I want to test my app look and feel on various mobiles. What is the reason for this and what configuration steps we have to follow to show my lightning console apps in mobile. I used following steps to test.
press-->f12 -->toggle device tool bar-->Responsive.

Thanks,
Mohan.
Hi Friends,
                   How to resolve System.NullPointerException Attempt to de-reference a null object in batch. Following is my code. Please suggest where do I made mistake in the below code. Out of 40 batches only one batch got failed.

global class UpdateBatch implements Database.Batchable<Sobject>,Schedulable{
    global string query = '';
    public static boolean issiteLocAuthrzsBatch =false;
    public Map<String,Map<String,Map<String,Prod_Authorization__c>>> hqmap = new Map<String,Map<String,Map<String,Prod_Authorization__c>>>();
    public List<Prod_Authorization__c> listToUpdate = new List<Prod_Authorization__c>();
    global id partnerRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Partner').getRecordTypeId();
    
    global void execute(schedulableContext sc){
        
    }
    global database.QueryLocator start(database.BatchableContext bc){
        query = 'select id,Account__c,Authorization_Type__c,Product_Name__c,Original_Active_Date__c,Status__c,Product_Category__c,Prod_Auth_Id__c, ' + 
            ' Account__r.Location_Type__c,Account__r.ParentId,Auth_Track_Sales__c,Sales_n__c,Auth_Track_Design__c,Design_n__c, ' +
            ' Auth_Track_Implement__c,Implement_n__c,Auth_Track_Maintain__c,Maintain_n__c,Account__r.Status__c FROM Prod_Authorization__c '+
            ' WHERE Account__r.RecordTypeId=\''+partnerRecTypeId+'\' and Account__r.Status__c =\'Active\'';
      return database.getQueryLocator(query);  
    }
    global void execute(database.BatchableContext bc, List<Prod_Authorization__c>authorizations){
        for(Prod_Authorization__c pa : authorizations){
            if(pa.Account__r.Location_Type__c == 'Headquarters' && pa.Account__r.Status__c=='Active'){
         if(!hqmap.containsKey(pa.Account__c)){
         hqmap.put(pa.Account__c,new Map<String,Map<String,Prod_Authorization__c>>{pa.Product_Name__c=>new Map<String,Prod_Authorization__c>{pa.Authorization_Type__c=>pa}});
       }else{
           if(hqmap.get(pa.Account__c).containsKey(pa.Product_Name__c)){
               hqmap.get(pa.Account__c).get(pa.Product_Name__c).put(pa.Authorization_Type__c,pa);
   }else {
            hqmap.get(pa.Account__c).put(pa.Product_Name__c,new Map<String,Prod_Authorization__c>());
            hqmap.get(pa.Account__c).get(pa.Product_Name__c).put(pa.Authorization_Type__c,pa);
   }
   }
               
            }
            
        } 
        for(Prod_Authorization__c pa : authorizations){
            if(pa.Account__r.Location_Type__c == 'Site Location' && pa.Account__r.Status__c== 'Active' && 
            pa.Account__r.ParentId!=null && hqmap.containsKey(pa.Account__r.ParentId)){   // here I got exception
            pa.Status__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Status__c;
 
          pa.Original_Active_Date__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Original_Active_Date__c;
            pa.Product_Category__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Product_Category__c;
            pa.Auth_Track_Sales__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Sales__c;
            pa.Sales_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Sales_n__c;
            pa.Auth_Track_Design__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Design__c;
            pa.Design_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Design_n__c;
            pa.Auth_Track_Implement__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Implement__c;
            pa.Implement_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Implement_n__c;
            pa.Auth_Track_Maintain__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Maintain__c;
            pa.Maintain_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Maintain_n__c;
            listToUpdate.add(pa);
            }
        }
        issiteLocAuthrzsBatch = true;
        if(!listToUpdate.isEmpty()){
        try{
        Database.SaveResult[] result =database.update(listToUpdate,false);
        }Catch(Exception e){
            system.debug('Exception:: '+e.getMessage());
        }
        }
    }
    global void finish(database.BatchableContext bc){
        
    }
}

Thanks,
Mohan S
Hi Friends,
                  I want to place multiple values for single unique key on the nested map. See below is the code.
Map<String,Map<String,Map<String,integer>>> nestedmap = new MAp<String,Map<String,Map<String,integer>>>();
   nestedmap.put('Country',new Map<String,Map<String,integer>>{'banglore'=>new Map<String,integer>{'Count'=>55}});
   nestedmap.put('Country',new Map<String,Map<String,integer>>{'banglore'=>new Map<String,integer>{'Count1'=>60}});
   nestedmap.put('Country',new Map<String,Map<String,integer>>{'Delhi'=>new Map<String,integer>{'Count2'=>45}});
  nestedmap.put('Country',new Map<String,Map<String,integer>>{'Delhi'=>new Map<String,integer>{'Count3'=>30}});
   system.debug('nestedmap: '+nestedmap);
The debug shows only last placed record into the map and it overwrites the before placed records with last one.
debug:  {Country={Delhi={Count3=45}}}.
I want to place duplicate values and later I have to use them in my code. Please suggest me how do I avoid the overwritting of duplicate values for the above map.

Thanks,
MohanS
 
Hi,
     I am getting the cannot reference converted lead exception in my class. I have a Matched Account lookup field on lead object. When i select the converted lead account for Matched Account on lead object then i try to convert this lead, where i am getting the above exception. Is this salesforce standard behaviour? Can we refer the converted lead account for new lead?


Thanks,
Mohan s
Hi,
     I have a query string in my batch It has lot of lines of query, when I run the batch It has throwing error like unexpected token <EOF> exception. I have debug this statement but in logs it was not traced. Query was not framed. How do I debug this efficiently.

Thanks,
Mohan S 
Hi,
     I want to get the jobname for the schedule class by using apex schedule class name or id. I don't know the when it was scheduled and job Name. Now I would like to add this schedule class and reschedule it again. When i try to add this job i am getting the following error "This Apex class has batch or future jobs pending or in progress" .


Thanks,
Mohan S
Hi,
        We have territories enabled. I want to query the Userterritory associated accounts. how do we get this. For example if we have ut1,ut2 and ut3. If user is changed from ut2 to  ut1 i want all the accounts under ut1,ut2 and ut3.

Thanks
Hi,
     I want to update the child territory account ownerid with parent territory account ownerids when parent territory changes to above level. how can we achieve this by using customization? Any suggestion can help me alot.
example: foe example there are four territory leves i.e level a top hierarchy level b, level c, and level d. If parent territory moves from level b to level a then all child territory accounts owners should be updated with  parent level territory accounts owner ids.
Hi,
    I am getting the following issue when launching the flow from the process. My requirement is to update the parent object when all the related childs are pass the criteria defined. I have Fund_Request__c is my parent object i want to update the status__c ='paid' when all the child records Payment_Status ='Paid'. Fund_Claim__c is my chld object is having Payment_Status__c picklist field.
I want to update the parent field when any child updated then i need to loop the all childs related to that parent.
Can any one help me to resolve this issue.
Error:The flow failed to access the value for eachFundClaim.Payment_Status__c because it hasn't been set or assigned.
My flow logic:
My Flow
Variables:
1.falseCounter: type: Number : Default:0
2.trueCounter:type:Number:default:0 
3.RequestId:type:Text(collecting the parentid from the pb).
SobjectVariable:
1.eachFundClaim :Input/output type: Object:Fund_Claim__c(Child)
Sobject Collection Variable: 
1.relatedFundClaims:input/output type:Object:Fund_Request__c(Parent)
Fast Lookup:
Look up : Fund_Claim__c
Field: FundRequest__c equals {!RequestId}
Variable: {!relatedFundClaims}
Loop:
Loop through :{!relatedFundClaims}
loop variable: {!eachFundClaim}
Decision: Name True Condition:
Resource: {!eachFundClaim.Payment_Status__c } equals {!GlobalConstant.True}
Assignment: variable:{!trueCounter} operator add value:1(I would like to add this counter for each loop element when it payment_status__c is checked)
Assignment: variable:{!falseCounter} operator add value:1
Decision: Resource: {!falseCounter} operator less than value 1
Record update:
Update : Fund_Request__c (Parent Object)
Field: Id equals {!RequestId} criteria
field : Status__c equals Paid
The following is the mail i received about the flow failure
low Details
Flow Name: MDF_Update_Process
Type: Record Change Process
Version: 12
Status: Active

Flow Interview Details
Interview Label: MDF_Update_Process-12_InterviewLabel
Current User: Mohan kumar (0057F000001kHT3)
Start time: 4/22/2018 8:24 AM
Duration: 0 seconds

How the Interview Started
Mohan kumar (0057F000001kHT3) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = a067F000006ZZEoQAO
myVariable_current = a067F000006ZZEoQAO

ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "4/22/2018 8:24 AM"

DECISION: isChangedDecision2_myRule_1_Payment_Status_c
Executed this outcome: isChangedRule_2_myRule_1_Payment_Status_c
Outcome conditions: and
1. {!myVariable_old} (a067F000006ZZEoQAO) Is null false
2. {!myVariable_old.Payment_Status__c} (false) Does not equal {!myVariable_current.Payment_Status__c} (true)
Logic: All conditions must be true (AND)

DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.FundRequests__c} (a057F000007KVvtQAG) Is null false
2. {!isChangedRule_2_myRule_1_Payment_Status_c} (true) Equals true
Logic: All conditions must be true (AND)

MDF_FLOW (FLOWS): myRule_1_A1
Inputs:
MDFRequestId = {!myVariable_current.FundRequests__c} (a057F000007KVvtQAG)
 
Hi All, 
         I am getting the to many soql 101 exception in the below class. How do i overcome this issue. Can any one help me to resolve this issue.
Trigger childafteraction on Child__c(after insert, after update){
Set<Id> ids = new Set<id>();
if(trigger.isInsert || trigger.isUpdate){
for(Child__c chlds :trigger.new){
ids.add(chlds.Parent__c);
}
}
new UpdateStatus().updateParent(ids);
}
==
public class UpdateStatus {
    public void updateParent(Set<Id> InputIds){
        Map<Id,Integer> parentMap = new Map<Id,Integer>();
        Map<Id,Integer> mapToCompare = new Map<Id,Integer>();
        Set<Id> idsToUpdate = new Set<Id>();
        for(Parent_Obj__c p:[SELECT id,Name, Status__c,Paid__c,(select id,name,Parent__c,Amount_Paid__c from RelationShipName where Parent__c IN:InputIds ) FROM Parent_Obj__c WHERE Id IN:InputIds]){ // here I am getting too many soql 101 exception
             parentMap.put(p.Id, p.RelationshipName__r.size()); 
        }
        for(AggregateResult result: [SELECT COUNT(Id), Parent__c FROM Child__c WHERE Amount_Paid__c=true AND Parent__c IN:InputIds GROUP BY Parent__c ]){ // here also i am getting too many soql 101 exception.
            Id pId = ((Id)result.get('Parent__c'));
            Integer count = ((Integer)result.get('expr0'));
            mapToCompare.put(pId,count);
        }
        if(!mapToCompare.isEmpty()){
        for(Id iterateIds :mapToCompare.keySet()){
            if(parentMap.containsKey(iterateIds) && parentMap.get(iterateIds) == mapToCompare.get(iterateIds)){
                idsToUpdate.add(iterateids);
            } 
        }
    }
        List<Parent__c> finalListToUpdate = new List<Parent__c>();
        if(!idsToUpdate.isEmpty()){
        for(Parent__c pIterate : [SELECT Id,Name,Status__c FROM Parent_Obj__c WHERE Id IN:idsToUpdate]){
           pIterate.Status__c = 'paid';
           finalListToUpdate.add(pIterate);
          }
           Database.SaveResult[] result =database.update(finalListToUpdate,false);
        }
    }
}
Hi All,
           I am unable to trace out how the field was shown on the chatter feed tracking, eventhough we don't havethat  field on the opportunity. We don't have Net Revenue field on the opportunity but the chatter feed tracking shows field update value on opportunity record detail page whenever updating the record. Any one suggest me the reason why it is happen? How do we trace out the cause?
hi friends,

               The following code is not working for delete event in trigger. But it's working fine for after insert and after update events.
I have custom object Revenue__c. It has master detail relationship with Account. I want to update Account field values with revenue field values whenever the revenue is inserted,updated and deleted.Can any one suggest me what is the wrong in the following code
trigger revenuetrigger on Revenue__c(after insert, after update,after delete){
if(trigger.isinsert || trigger.isupdate ){
new RevenueCal().populateRevenu(trigger.new);
}if(trigger.isdelete){
new RevenueCal().populateRevenu(trigger.old);
}
}
Apex class:
public class RevenueCal {
    Map<Id,Account> accmap = new Map<Id,Account>();
   public List<Id> ids = new List<Id>(accmap.keySet());
    public List<Account> childsToupdate = new List<Account>();
    //ids.addAll();
   public map<String,Revenue__c> linkIdMap = new Map<String,Revenue__c>();
    List<Account>listToUpdate = new List<Account>();
    public void populateRevenue(List<Revenue__c> revlist){
        for(Revenue__c rev : revlist){
           linkIdMap.put(rev.Reporting_Link_Id__c, rev);
          
        }
        //update listToupdate;
        for(Account a : [SELECT Id, Name,Link_Id__c,ParentId,Reporting_Link_Id__c,Revenue_Product__c,
                         Revenue_Service__c,Revenue_Cloud__c FROM Account]){
            if(linkIdmap.containsKey(a.Reporting_Link_Id__c)){
                a.Revenue_Product__c = linkIdmap.get(a.Reporting_Link_Id__c).Product_Revenue__c;
                a.Revenue_Service__c = linkIdmap.get(a.Reporting_Link_Id__c).Service_Revenue__c;
                a.Revenue_Cloud__c = linkIdmap.get(a.Reporting_Link_Id__c).Cloud_Revenue__c;
                childsToupdate.add(a);
            }
        }
        try{
        update childsToupdate;
        }Catch(Exception e){
            system.debug('update failes due to:'+e.getMessage());
        }
    }
}
Hi Friends,

                  I am geeting the following issue when i try to check the syntax error on onclick javascript button. "Syntax error &". in the following code. Can any one please help me resolving this issue.
Code:
{!REQUIRESCRIPT(&quot;/soap/ajax/38.0/connection.js&quot;)} 
{!REQUIRESCRIPT(&quot;/soap/ajax/38.0/apex.js&quot;)} 
try 


var partnerType; 
var accList = []; 
var result = sforce.connection.query( 
&quot;Select Id, Name,Account__c,RecordType.Name,Account__r.Partner_Type_New__c FROM custom_c where id=&apos;{!custom__c.Id}&apos; &quot;); 
var iter = new sforce.QueryResultIterator(result); 

while(iter.hasNext()) 

var record=iter.next(); 
partnerType = record.RecordType.Name;
accList.push(record.Account__c); 

if(partnerType==&apos;customer&apos;) 

sforce.apex.execute(&quot;SampleClass&quot;,&quot;sampleMethod1&quot;,{refreshAccList:accList}); 
parent.window.location = &quot;{! URLFOR($Action.custom__c.View,custom__c.Id,null)}&quot;; 
}
else if(partnerType ==&apos;newcustomer&apos;){ 
sforce.apex.execute(&quot;Sampleclass1&quot;,&quot;sampleMethod&quot;,{refAccList:accList}); 
parent.window.location = &quot;{! URLFOR($Action.custom__c.View,custom__c.Id,null)}&quot;; 
}

catch(err){ 
alert(err); 
alert(&quot;System is currently unable to process your request.&quot;); 
}
Hi Friends,

                 I am getting following Issue when try to retrieve code using force.com migration tool."Access is denied". Can any one suggest me what is this Issue.I have copied the force.com migration tool in F drive. I used the following command to retieve 
C:\Users\lenovo>F:

F:\>cd F:\Ant>ant retrieveCode
Access is denied.

F:\>
Hi Fiends,

                 I am using batch apex for inserting the 100000 records but, the following exception throws while executing the batch. System.LimitException: "Too many DML rows:10001". I have tried giving batch size  as low and maximum but in both the cases the it throws the same exception.

global class InsertionOfOneLakhRecords implements database.Batchable<Sobject>,database.stateful{
   public integer count = 0;
  global database.QueryLocator start(database.BatchableContext bc){
    return database.getQueryLocator('select id, Name FROM Contact');
}
global void execute(database.BatchableContext bc, List<Contact> sobj){
    List<Contact> cons = new List<Contact>();
   for(integer i=0; i<100000; i++){
    Contact c = new Contact(LastName = 'test'+i, Email='test@salesforce.com', Phone = '123456');
    count++;
    cons.add(c);
}
    try{
    Database.SaveResult[] result =database.insert(cons);
 }
    catch(exception e){
     system.debug('Exception:'+e.getMessage());
    }
}
global void finish(database.BatchableContext bc){
 system.debug('total:'+count);   
  }
}

Thanks & Regards
Hi Friends,
I am getting following bug while testing my controller "System.QueryException: line 6:730 no viable alternative at character 'a' ". Can any one help how to resolve it. Can any one tell me is the following query is correct or not if it is wrong modify the query and give me reply as correct query your help is really appreciable. I hope i receive reply.
In the following query i am passing SiteIds, procedures and patientage as a string of values dynamically but they are not passed to the query.
I ahve written the query like this
 conditionQuery =     ' AND Patient__r.IsActive__c = true ' +
                             ' AND Patient__r.Site_Id__c IN : siteIds ' +
                             ' AND Patient__c IN : patEnrollTeamIds' +
                             ' AND Patient__r.Patient__r.Gender__c IN : gender ' +
                             ' AND Patient__r.Patient__r.Age_Group__c IN : patientAge ' +
                             ' AND Patient__r.Surgery_Type__c IN : procedures ' +
                             ' AND Patient__r.ASA_Score__c IN : asascore ';

This is debug log:
Final Query :Select Text_Field__c, Patient_Survey__r.Patient__r.Id, Patient_Survey__r.Patient__r.Patient__r.First_Name__c, ER_DOS_Delta__c, Patient_Survey__r.Patient__r.Patient__r.Last_Name__c,LOS__c, Patient_Survey__r.Patient__r.Surgery_Date__c,Number__c, Patient_Survey__r.Patient__r.Surgery_Type__c,Patient_Survey__r.Patient__r.ASA_Score__c, Patient_Survey__r.Patient__r.Patient_Enrollment_Status__c, Patient_Survey__r.Patient__r.Percent_Survey_Completed__c,Patient_Survey__r.Patient__r.Missed_Surveys__c,Patient_Survey__r.Patient__r.Other_Pain_Management_used_if_any__c From Patient_Responses__c WHERE Number__c != null AND IsDemo__c =false AND Question_Pattern__c = 'Group' AND Group_Name__c = 'Pain' AND Patient_Survey__r.Survey_Status__c IN ('Completed', 'In-Progress' , 'Expired') AND Category__c LIKE '%Rest%' AND Patient_Survey__r.Name= 'Post Surgery, day 3' AND Patient_Survey__r.Patient__r.Patient__r.Account__c in :siteIds AND Patient_Survey__r.Patient__c IN : patEnrollTeamIds AND Patient_Survey__r.Patient__r.Surgery_Type__c in :procedures AND Patient_Survey__r.Patient__r.Patient__r.Age_Group__c in :patientAge AND Patient_Survey__r.Patient__r.Patient__r.Gender__c in :gender AND Patient_Survey__r.Patient__r.ASA_Score__c IN : asascore AND DAY_ONLY(Createddate) <=2017-08-10 00:00:00and DAY_ONLY(Createddate) >=2017-01-10 00:00:00 ORDER BY Patient_Survey__r.Name LIMIT 1000
 global class SelectedFilters{
        public Set<String> SiteIds{get;set;}
        public Set<String> surgeonIds{get;set;}
        public Set<string> anesthesiologistIds{get;set;}
        public List<String> procedures{get;set;}
        public List<string> ONQUsed{get;set;}
        public List<string> patientAge{get;set;}
        public List<string> gender{get;set;}
        public string onload {get;set;}
        public List<string> PainManagementUsed{get;set;}
        public List<String> HospitalName {get;set;}
        public List<String> ASAScore {get;set;}
        
        public SelectedFilters(Set<String> siteIds, /*Boolean is_ReadOnlySite,*/
                             Set<String> surgeonIds,Set<String> anesthesiologistIds,
                             List<String> procedures,List<string> ONQUsed,
                             List<string> patientAge,List<string> gender,
                             List<string> PainManagementUsed , List<String> HospitalName,List<String> ASAScore) {
            this.siteIds = siteIds;
            this.surgeonIds = surgeonIds;
            this.anesthesiologistIds = anesthesiologistIds;
            this.procedures = procedures;
            this.ONQUsed= ONQUsed;
            this.patientAge= patientAge;
            this.gender= gender;
            this.PainManagementUsed= PainManagementUsed;
            this.HospitalName = HospitalName;
            this.ASAScore = ASAScore;
        }
==
 JSONstring ='{"siteIds":["'+String.valueof(testAccount.id)+
            '"],"surgeonIds":["' +String.valueof(testContact.id)+
            '"],"anesthesiologistIds":["'+String.valueof(testContact.id) +
            '"],"procedures":["Lap BSO"],"ONQUsed":["Yes"],"patientAge":["0-18","18 – 29"],"gender":["Male","Female"],"PainManagementUsed":["ON-Q","Single Injection nerve block","Wound infusion","Local infiltration"],"HospitalName":["ABC","DEF"],"ASAScore":["I"]}';
      
 if(String.isNotBlank(jsonString))
        {
            EngagementGraphsController.SelectedFilters test  = (EngagementGraphsController.SelectedFilters)JSON.deserialize(jsonString,EngagementGraphsController.SelectedFilters.class);
            system.debug('-----------test :'+test);  
            
            EngagementGraphsController.SelectedFilters currentFilter = EngagementGraphsController.generateFilterWrapper(jsonString);
            Set<String> siteIds = currentFilter.SiteIds;
            Set<String> surgeonIds = currentFilter.surgeonIds;
            Set<String> anesthesiologistIds = currentFilter.anesthesiologistIds;
            List<String> procedures = currentFilter.procedures;
            List<string> painMgmntUsed = currentFilter.PainManagementUsed;
            List<string> patientAge = currentFilter.patientAge;
            List<string> gender = currentFilter.gender;
            List<string> hospital = currentFilter.HospitalName;
            List<string> asascore = currentFilter.ASAScore;
     
Hi Friends,
I am getting the following bug while performing test to the apex controller the test class is failed due to the following error can any one please tell me what it is and how to resolve it. "System.JSONException: Malformed JSON: Expected '{' at the beginning of object"
Class.EngagementGraphsController.generateFilterWrapper: line 253, column 1
Class.ChartDrillDownController.getDrilldownPatientsData: line 39, column 1
Class.ChartDrillDownController_Test.patientdataTest: line 86, column 1
Test class:
/*Developer: Rambabu
Description: This is test class of ChartDrillDowncontroller*/
@istest
public class ChartDrillDownController_Test{
   static Account testAccount;
    static Contact testContact;
     static User user =[SELECT Id, Name from User WHERE Alias='rbabu'];
      static List<Patient_Enrollment__c> enrollmentTestList = new List<Patient_Enrollment__c>();
    static string chartInput='{"xAxis":"2017-08-01","legend":"TOTAL_INVITED","chartName":"PATIENT_ENGAGEMENT"}';
         static String FromDateString = '2017, 01, 01';
        static String ToDateString = '2017, 08, 09';
       static boolean isDemo = true;
      static date startDate = date.newInstance(2016,08,10);
     static date endDate = date.newInstance(2017,08,10);
    Static String JSONstring = '{"siteIds":["001c000001BydRwAAJ"],"surgeonIds":["003c000000ph8dEAAQ"],"anesthesiologistIds":["003c000000ph8cqAAA"],"procedures":["Axillary Dissection", "Bilateral Mastectomy", "Hiatal Hernia Repair", "Hysterectomy with Staging", "Hysteroscopy D&C", "Lap Cholecystectomy", "Lap-assisted Hysterectomy", "Laparoscopic Supracervical Hysterectomy", "Laparotomy", "Liver transplant"],"HospitalName":["ABC","DEF"],"patientAge":["0-18","18 – 29","30 – 39","40 – 49","50 – 59","60 – 69","70 – 79",">80"],"gender":["Male","Female"],"PainManagementUsed":["ON-Q","Single Injection nerve block","Wound infusion","Local infiltration"]}';
    @testSetup static void setupTestData(){
        testAccount = new Account(Name='testAccount',Site_Display_Name__c='testsite',Start_Date__c=startDate,End_Date__c=endDate,Email__c='test@hyh.com',Sales_Rep__c=user.id,Status__c='Active',OwnerId=user.id);
        testContact = new Contact(LastName='contact', FirstName='test',AccountId=testAccount.Id,Email='testmail@hyh.com',Role__c='Surgeon',Surgical_Specialty__c='General Surgery');
        for(integer i=0; i<100; i++){
            Patient_Enrollment__c pe = new Patient_Enrollment__c();
            pe.Patient_First_Name__c = 'enrollment';
            pe.Patient_Last_Name__c = 'test'+i;
            pe.Patient_Phone_Number__c = '02064546025';
            pe.Patient_Email__c = 'patienttestmail@hyh.com';
            pe.Date_of_Birth__c = date.newInstance(1980,05,12);
            if(i<=50){
            pe.Gender__c = 'Male';
            pe.Patient_Enrollment_Status__c = 'Active - Accepted';
            }
            else{
            pe.Gender__c = 'Female';
            pe.Patient_Enrollment_Status__c = 'Active - Invited';
            }
            pe.Surgery_Date__c = date.newInstance(2017,08,1);
            pe.Surgeon__c = testcontact.id;
            pe.Surgery_Type__c = 'Lap BSO';
            pe.Surgeon__c = testContact.Id;
            pe.Anesthesiologist__c = testContact.Id;
            pe.On_Q_Used__c = 'Yes';
            pe.On_Q_pump_Model_used__c = 'CB003';
            pe.Other_Pain_Management_used_if_any__c = 'Wound infusion';
            pe.IsDemo__c = true;
            enrollmentTestList.add(pe);  
    }
            insert enrollmentTestList;
        system.debug('Patient Enrollment List:'+enrollmentTestList.size());
            SurveyTemplate__c template = new SurveyTemplate__c();
             template.Survey_Template_Name__c  = 'test template';
             template.Available_From__c = '1';
             template.Available_To__c = '3';
             template.Survey_Day_Email_Time__c ='8:00';
             template.Email_Reminder_Time__c = '7:00';
             template.SMS_Reminder_Time__c ='6:00';
             template.Survey_Order__c =2;
           insert template;
        system.debug('Template Id:'+template.Id);
             List<Patient_Survey__c> surveyList = new List<Patient_Survey__c>();
             for(integer i=0; i<10; i++){
                Patient_Survey__c ps = new Patient_Survey__c();
                ps.Name = 'test survey'+i;
                ps.IsDemo__c = true;
                ps.Patient__c = enrollmentTestList[i].id;
                ps.Survey_Name__c = template.id;
                surveyList .add(ps);
      }
       insert surveyList;
        system.debug('SurveyList Size:'+surveyList.size());
       List<Patient_Responses__c> surveyResponseList = new List<Patient_Responses__c>();
       for(integer i=0; i<=10; i++){
           Patient_Responses__c psr = new Patient_Responses__c();
           psr.Patient_Survey__c = surveyList[0].id;
           psr.Selected_Medication_List__c = 'Celebrex';
           psr.Opioid__c = true;
           psr.Question_Pattern__c='Dependent';
           psr.Section_Name__c = 'side effects';
           psr.Answer__c = 'Dizziness;Constipation';
           psr.IsDemo__c  = false;
           surveyResponseList.add(psr);
       }
       insert surveyResponseList;
        system.debug('Survey response List size:'+surveyResponseList);
  }
    static testmethod void patientdataTest(){
        system.runAs(user){
          test.startTest();
        ChartDrillDownController.getDrilldownPatientsData(JSONString,chartInput,FromDateString,ToDateString,isDemo);
        //ChartDrillDownController.getDrilldownPatientsDataForOutcome(chartInput,FromDateString,ToDateString,JSONString,isDemo);
        test.stopTest();
        }
     }
}
 
Hi Friends,
I read in apex developer guide we can't deploy the email service address name. Can  any one help me how we deploy the email service address name?
Thank you
Hi Friends,
I read in apex developer guide we can't deploy the email service address name. Can  any one help me how we deploy the email service address name?
Thank you
This is my code
=============
global class BatchApex implements Database.Batchable<sobject>{
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('select id from Opportunity');
        
    }
    global void execute(Database.BatchableContext bc,List<Opportunity>scope){
        for(Opportunity o:scope){
            o.Name='sandhya';
        }
    update scope;
}
    global void finish(Database.BatchableContext bc){
            
   Messaging.SingleEmailMessage[] mail=new Messaging.SingleEmailMessage();
        String[] toAddresses=new String[] {'forcesfdcloud@gmail.com'};
            mail.setToAddresses(toAddresses);
        mail.setSubject('sending mail ');
        mail.setPlainTextBody('process completed success fully');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
      
    }
    }
I want to update my opportunities. After updating the opportunities i want to send a mail to the above mentioned address, but it shows error like" Illegal assignment from Messaging.SingleEmailMessage to List<Messaging.SingleEmailMessage>" can any one tell me how to solve this issue.
Hi,
How do we @JsonAccess annotation for deserializing the json. Can anyone give example code. I want to deseralize below json
{"Details":[{"FirstName":"Name","LastName":"lastname","Email":"sample@mail.com"},{"FirstName":"Name","LastName":"lastname","Email":"sample@mail.com"}]
Thanks,
Mohan
Hi Friends,
                   How to resolve System.NullPointerException Attempt to de-reference a null object in batch. Following is my code. Please suggest where do I made mistake in the below code. Out of 40 batches only one batch got failed.

global class UpdateBatch implements Database.Batchable<Sobject>,Schedulable{
    global string query = '';
    public static boolean issiteLocAuthrzsBatch =false;
    public Map<String,Map<String,Map<String,Prod_Authorization__c>>> hqmap = new Map<String,Map<String,Map<String,Prod_Authorization__c>>>();
    public List<Prod_Authorization__c> listToUpdate = new List<Prod_Authorization__c>();
    global id partnerRecTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Partner').getRecordTypeId();
    
    global void execute(schedulableContext sc){
        
    }
    global database.QueryLocator start(database.BatchableContext bc){
        query = 'select id,Account__c,Authorization_Type__c,Product_Name__c,Original_Active_Date__c,Status__c,Product_Category__c,Prod_Auth_Id__c, ' + 
            ' Account__r.Location_Type__c,Account__r.ParentId,Auth_Track_Sales__c,Sales_n__c,Auth_Track_Design__c,Design_n__c, ' +
            ' Auth_Track_Implement__c,Implement_n__c,Auth_Track_Maintain__c,Maintain_n__c,Account__r.Status__c FROM Prod_Authorization__c '+
            ' WHERE Account__r.RecordTypeId=\''+partnerRecTypeId+'\' and Account__r.Status__c =\'Active\'';
      return database.getQueryLocator(query);  
    }
    global void execute(database.BatchableContext bc, List<Prod_Authorization__c>authorizations){
        for(Prod_Authorization__c pa : authorizations){
            if(pa.Account__r.Location_Type__c == 'Headquarters' && pa.Account__r.Status__c=='Active'){
         if(!hqmap.containsKey(pa.Account__c)){
         hqmap.put(pa.Account__c,new Map<String,Map<String,Prod_Authorization__c>>{pa.Product_Name__c=>new Map<String,Prod_Authorization__c>{pa.Authorization_Type__c=>pa}});
       }else{
           if(hqmap.get(pa.Account__c).containsKey(pa.Product_Name__c)){
               hqmap.get(pa.Account__c).get(pa.Product_Name__c).put(pa.Authorization_Type__c,pa);
   }else {
            hqmap.get(pa.Account__c).put(pa.Product_Name__c,new Map<String,Prod_Authorization__c>());
            hqmap.get(pa.Account__c).get(pa.Product_Name__c).put(pa.Authorization_Type__c,pa);
   }
   }
               
            }
            
        } 
        for(Prod_Authorization__c pa : authorizations){
            if(pa.Account__r.Location_Type__c == 'Site Location' && pa.Account__r.Status__c== 'Active' && 
            pa.Account__r.ParentId!=null && hqmap.containsKey(pa.Account__r.ParentId)){   // here I got exception
            pa.Status__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Status__c;
 
          pa.Original_Active_Date__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Original_Active_Date__c;
            pa.Product_Category__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Product_Category__c;
            pa.Auth_Track_Sales__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Sales__c;
            pa.Sales_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Sales_n__c;
            pa.Auth_Track_Design__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Design__c;
            pa.Design_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Design_n__c;
            pa.Auth_Track_Implement__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Implement__c;
            pa.Implement_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Implement_n__c;
            pa.Auth_Track_Maintain__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Auth_Track_Maintain__c;
            pa.Maintain_n__c = hqmap.get(pa.Account__r.ParentId).get(pa.Product_Name__c).get(pa.Authorization_Type__c).Maintain_n__c;
            listToUpdate.add(pa);
            }
        }
        issiteLocAuthrzsBatch = true;
        if(!listToUpdate.isEmpty()){
        try{
        Database.SaveResult[] result =database.update(listToUpdate,false);
        }Catch(Exception e){
            system.debug('Exception:: '+e.getMessage());
        }
        }
    }
    global void finish(database.BatchableContext bc){
        
    }
}

Thanks,
Mohan S
Hi Friends,
                  I want to place multiple values for single unique key on the nested map. See below is the code.
Map<String,Map<String,Map<String,integer>>> nestedmap = new MAp<String,Map<String,Map<String,integer>>>();
   nestedmap.put('Country',new Map<String,Map<String,integer>>{'banglore'=>new Map<String,integer>{'Count'=>55}});
   nestedmap.put('Country',new Map<String,Map<String,integer>>{'banglore'=>new Map<String,integer>{'Count1'=>60}});
   nestedmap.put('Country',new Map<String,Map<String,integer>>{'Delhi'=>new Map<String,integer>{'Count2'=>45}});
  nestedmap.put('Country',new Map<String,Map<String,integer>>{'Delhi'=>new Map<String,integer>{'Count3'=>30}});
   system.debug('nestedmap: '+nestedmap);
The debug shows only last placed record into the map and it overwrites the before placed records with last one.
debug:  {Country={Delhi={Count3=45}}}.
I want to place duplicate values and later I have to use them in my code. Please suggest me how do I avoid the overwritting of duplicate values for the above map.

Thanks,
MohanS
 
Hi,
     I am getting the cannot reference converted lead exception in my class. I have a Matched Account lookup field on lead object. When i select the converted lead account for Matched Account on lead object then i try to convert this lead, where i am getting the above exception. Is this salesforce standard behaviour? Can we refer the converted lead account for new lead?


Thanks,
Mohan s
Hi,
        We have territories enabled. I want to query the Userterritory associated accounts. how do we get this. For example if we have ut1,ut2 and ut3. If user is changed from ut2 to  ut1 i want all the accounts under ut1,ut2 and ut3.

Thanks
Hi All, 
         I am getting the to many soql 101 exception in the below class. How do i overcome this issue. Can any one help me to resolve this issue.
Trigger childafteraction on Child__c(after insert, after update){
Set<Id> ids = new Set<id>();
if(trigger.isInsert || trigger.isUpdate){
for(Child__c chlds :trigger.new){
ids.add(chlds.Parent__c);
}
}
new UpdateStatus().updateParent(ids);
}
==
public class UpdateStatus {
    public void updateParent(Set<Id> InputIds){
        Map<Id,Integer> parentMap = new Map<Id,Integer>();
        Map<Id,Integer> mapToCompare = new Map<Id,Integer>();
        Set<Id> idsToUpdate = new Set<Id>();
        for(Parent_Obj__c p:[SELECT id,Name, Status__c,Paid__c,(select id,name,Parent__c,Amount_Paid__c from RelationShipName where Parent__c IN:InputIds ) FROM Parent_Obj__c WHERE Id IN:InputIds]){ // here I am getting too many soql 101 exception
             parentMap.put(p.Id, p.RelationshipName__r.size()); 
        }
        for(AggregateResult result: [SELECT COUNT(Id), Parent__c FROM Child__c WHERE Amount_Paid__c=true AND Parent__c IN:InputIds GROUP BY Parent__c ]){ // here also i am getting too many soql 101 exception.
            Id pId = ((Id)result.get('Parent__c'));
            Integer count = ((Integer)result.get('expr0'));
            mapToCompare.put(pId,count);
        }
        if(!mapToCompare.isEmpty()){
        for(Id iterateIds :mapToCompare.keySet()){
            if(parentMap.containsKey(iterateIds) && parentMap.get(iterateIds) == mapToCompare.get(iterateIds)){
                idsToUpdate.add(iterateids);
            } 
        }
    }
        List<Parent__c> finalListToUpdate = new List<Parent__c>();
        if(!idsToUpdate.isEmpty()){
        for(Parent__c pIterate : [SELECT Id,Name,Status__c FROM Parent_Obj__c WHERE Id IN:idsToUpdate]){
           pIterate.Status__c = 'paid';
           finalListToUpdate.add(pIterate);
          }
           Database.SaveResult[] result =database.update(finalListToUpdate,false);
        }
    }
}
Hi Friends,

                  I am geeting the following issue when i try to check the syntax error on onclick javascript button. "Syntax error &". in the following code. Can any one please help me resolving this issue.
Code:
{!REQUIRESCRIPT(&quot;/soap/ajax/38.0/connection.js&quot;)} 
{!REQUIRESCRIPT(&quot;/soap/ajax/38.0/apex.js&quot;)} 
try 


var partnerType; 
var accList = []; 
var result = sforce.connection.query( 
&quot;Select Id, Name,Account__c,RecordType.Name,Account__r.Partner_Type_New__c FROM custom_c where id=&apos;{!custom__c.Id}&apos; &quot;); 
var iter = new sforce.QueryResultIterator(result); 

while(iter.hasNext()) 

var record=iter.next(); 
partnerType = record.RecordType.Name;
accList.push(record.Account__c); 

if(partnerType==&apos;customer&apos;) 

sforce.apex.execute(&quot;SampleClass&quot;,&quot;sampleMethod1&quot;,{refreshAccList:accList}); 
parent.window.location = &quot;{! URLFOR($Action.custom__c.View,custom__c.Id,null)}&quot;; 
}
else if(partnerType ==&apos;newcustomer&apos;){ 
sforce.apex.execute(&quot;Sampleclass1&quot;,&quot;sampleMethod&quot;,{refAccList:accList}); 
parent.window.location = &quot;{! URLFOR($Action.custom__c.View,custom__c.Id,null)}&quot;; 
}

catch(err){ 
alert(err); 
alert(&quot;System is currently unable to process your request.&quot;); 
}
Hi Friends,

                 I am getting following Issue when try to retrieve code using force.com migration tool."Access is denied". Can any one suggest me what is this Issue.I have copied the force.com migration tool in F drive. I used the following command to retieve 
C:\Users\lenovo>F:

F:\>cd F:\Ant>ant retrieveCode
Access is denied.

F:\>
Hi Fiends,

                 I am using batch apex for inserting the 100000 records but, the following exception throws while executing the batch. System.LimitException: "Too many DML rows:10001". I have tried giving batch size  as low and maximum but in both the cases the it throws the same exception.

global class InsertionOfOneLakhRecords implements database.Batchable<Sobject>,database.stateful{
   public integer count = 0;
  global database.QueryLocator start(database.BatchableContext bc){
    return database.getQueryLocator('select id, Name FROM Contact');
}
global void execute(database.BatchableContext bc, List<Contact> sobj){
    List<Contact> cons = new List<Contact>();
   for(integer i=0; i<100000; i++){
    Contact c = new Contact(LastName = 'test'+i, Email='test@salesforce.com', Phone = '123456');
    count++;
    cons.add(c);
}
    try{
    Database.SaveResult[] result =database.insert(cons);
 }
    catch(exception e){
     system.debug('Exception:'+e.getMessage());
    }
}
global void finish(database.BatchableContext bc){
 system.debug('total:'+count);   
  }
}

Thanks & Regards
Notes / Attachment on opporutnity only then allow to create Opportunity Line Item
i was a trying the below code and getting  an error can anyone please let me know what is the mistake i am doing the error is " Error: Unknown property 'AccountStandardController.Location' " what i could understand from the error is Location is not getting referenced pls help 

<apex:page standardController="Account">
 <apex:form >
  <apex:outputPanel id="locationPicker">
<apex:outputField value="{!Location.country}">
<apex:inlineEditSupport event="ondblClick" />
</apex:outputField>
</apex:outputpanel>
  </apex:form>
</apex:page>

I have the following code.
When Subcategory is Retailer Street, another field called Chain should appear but i get the following error in popup: 
ReferenceError: Customer_Seling_Type__c is not defined

Can anyone help me please?
<apex:page standardController="Customer_Seling_Type__c" id="pg">
      <apex:form id="frm">
            <apex:pageBlock title="Javascript Example" id="pgBlock" >
                 <apex:pageBlockSection title="Checkbox Example" id="pbSec"> 
                      <apex:inputField id="cc" value="{!Customer_Seling_Type__c.Subcategory__c}" label="Do not call" onchange="tt(this);"/>
                      <apex:pageBlockSectionItem id="pbsi">
                          <apex:outputLabel value="Languages" id="lblLang" ></apex:outputLabel>
                          <apex:inputField id="languageCtrl" value="{!Customer_Seling_Type__c.Chain__c}" />
                      </apex:pageBlockSectionItem>
                 </apex:pageBlockSection>
            </apex:pageBlock>
      
      </apex:form>

      <script>
         function tt(chkboxCtrl) {
         
             try {
                      // hide if checked
                      if( Customer_Seling_Type__c.Subcategory__c =="Retailer Street" ) {
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.languageCtrl}').style.display = 'inline';
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.lblLang}').style.display = 'inline';
                      }
                      else {
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.languageCtrl}').style.display = 'none';
                          document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.lblLang}').style.display = 'none';
                      }
                      
                      
              }
              catch(e) {
                  alert(e);
              }
         }
         
         document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.languageCtrl}').style.display = 'none';
         document.getElementById('{!$Component.frm.pgBlock.pbSec.pbsi.lblLang}').style.display = 'none';
         
   </script>   
</apex:page>



 
Hi Friends,
I have code coverage issue while writing a test class for the trigger. One line is not passed the code coverage I did not find the reason, why it is not .Can any one suggest me the reason. I am getting 87% code coverage.
Trigger:
trigger AccountsProcessorTrig on Account (after insert) {
    if(trigger.isInsert){
       AccountProcessor.countContacts(trigger.newMap.keySet()); 
    }
}
Apex Class:
public class AccountProcessor {
    public static integer count=0;
@future
    public static void countContacts(set<Id> accountids){
        List<Account> accountstobulkify=[SELECT Id, Name FROM Account WHERE Id IN:accountids];
        Map<Id,Account> accountstoupdate=new Map<Id,Account>();
        for(Account a:accountstobulkify){
            for(Contact c:a.Contacts){
                count=count++;// this line is not passed
            } 
        a.Number_Of_Contacts__c=count;
        }
        
     }


Test class:
@isTest
private class AccountProcessorTest {
@isTest
    static void CountNoOfContacts(){
        Account testacc=new Account(Name='Numberofcontactstest',Industry='Finance');
        insert testacc;
        List<Contact> testlist=new List<Contact>();
        for(integer i=0; i<10; i++){
            Contact testcon=new Contact(LastName='AccountContact'+i, AccountId=testacc.id);
            testlist.add(testcon);
        }
        insert testlist;
        system.debug('size:'+testlist.size());
        Map<Id,Account> testids=new Map<Id,Account>([SELECT Id, Name, Number_Of_Contacts__c FROM Account WHERE Name=:'Numberofcontactstest']);
        Set<Id> accids=testids.keySet();
        system.debug('Contcts:'+([SELECT Count() FROM Contact WHERE AccountId=:testacc.Id]));
        test.startTest();
        AccountProcessor.countContacts(accids);
        test.stopTest();
        decimal a=[SELECT ID, Name FROM Account WHERE Name=:'Numberofcontactstest'].Number_Of_Contacts__c;
        system.assertEquals(10, a);
    }
}
 
Hi, Friends
I want to display selected Account record as pdf format when I select the checkboxes those records only displayed in pdf format. I tried this scenario but the page has not displayed the content of the record. it displays only empty pdf page. Please go through the following code which i had developed in my org. Please let me know what mistake I had made in the code.
Controller
public class PdfController {
 public List<Account> initialList {get;set;}
    public List<Account> selectedlist {get;set;}
    public List<InnerWrapper> wlist {get;set;}
    public PdfController() {
      initialList=new List<Account>();
        wlist=new List<InnerWrapper>();
        InnerWrapper iw;
      initialList=[SELECT Id, Name, Industry FROM Account LIMIT 10]; 
        for(Account a:initialList){
            iw=new InnerWrapper();
            iw.unselected=a;
            wlist.add(iw);
        }
    }
    public PageReference displaySelected() {
        selectedlist=new List<Account>();
        for(InnerWrapper selectedaccount:wlist){
            if(selectedaccount.selectacc){
               selectedlist.add(selectedaccount.unselected);
           }
        } 
        PageReference p=page.pdfpage;
        return p;
    }
   
    public class InnerWrapper {
        public boolean selectacc{get;set;}
        public Account unselected {get;set;}
    }
}
Vfpage1
<apex:page controller="PdfController">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable title="Accounts" value="{!wlist}" var="iterate">
            <apex:column headerValue="selectAccount">
                <apex:inputCheckbox value="{!iterate.selectacc}"/>
            </apex:column>
            <apex:column headerValue="Name" value="{!iterate.unselected.Name}"/>
            <apex:column headerValue="Print">
                <apex:commandButton value="download" action="{!displaySelected}"/>
            </apex:column>
        </apex:pageBlockTable>
      </apex:pageBlock>
  </apex:form>
</apex:page>
<apex:page controller="PdfController">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable title="Accounts" value="{!wlist}" var="iterate">
            <apex:column headerValue="selectAccount">
                <apex:inputCheckbox value="{!iterate.selectacc}"/>
            </apex:column>
            <apex:column headerValue="Name" value="{!iterate.unselected.Name}"/>
            <apex:column headerValue="Print">
                <apex:commandButton value="download" action="{!displaySelected}"/>
            </apex:column>
        </apex:pageBlockTable>
      </apex:pageBlock>
  </apex:form>
</apex:page>
Vfpage2
<apex:page controller="PdfController" showHeader="false">
    <apex:pageBlock >   
    <apex:pageBlockTable value="{!selectedlist}" var="a">
   <apex:pageBlockSection columns="2">
       <apex:outputField value="{!a.Name}"/>
        </apex:pageBlockSection>
        </apex:pageBlockTable>
        </apex:pageBlock>
</apex:page>
Hi Friends,

I am getting following error in my trigger while ignoring the casesensitive. can any one help me what mistake did i made in the following trigger.
My requirement is to autopopulate Region__c custom field in Account when i give Account billing country. For this requirement I have created custom setting called country_Names__c with country_Region as custom field. without containsIgnoreCase it is working fine but when i try to enter Billingcountry in lowercase the Region__c field is not autopopulated for this i want to ignore the caseinsensitive.
error:"Method does not exist or incorrect signature: [Set<String>].containsIgnoreCase(String)"
trigger:
trigger ReportsAccount on Account (before insert, before update) {
    Map<string,Country_Names__c> countries=Country_Names__c.getAll();//get all the countries
     set<string> countrynames= new set<string>();
    countrynames.addAll(countries.keySet()); // add map country keys to set
    if(trigger.isInsert){
    for(Account a:trigger.new){
        if(countrynames.containsIgnoreCase(a.BillingCountry)){  //error line without ignore case it is working fine
            a.Region__c=countries.get(a.BillingCountry).Country_Region__c;
        }
    } // loop ends
    }
    if(trigger.isUpdate){
        for(Account updateacc: trigger.new){
            if(countrynames.contains(updateacc.BillingCountry)){
              updateacc.Region__c=countries.get(updateacc.BillingCountry).Country_Region__c;  
            }  
        }// loop ends
    }
}
Hi Friends,
I have custom field called NoContact__c It is a decimal data type in Account object,. My requirement is to increment the NoContact__c field each time when i try to insert the contact for associated account.And when i delete the contact that associate with Account, The NoContact__c  filed should be decremented. For this requirement i had written trigger in this trigger inserting operation is working fine but when i try to perform delete operation it throws the following error. Can any one help me what mistake did i made in this trigger.

Error: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object: External entry point".

Apex trigger:
    trigger countcontacts on Contact (after insert,before delete) {
      List<Contact>conlist=[SELECT Id,Name,contact.AccountId,Contact.Account.NoContact__c FROM Contact WHERE Id IN:trigger.new];
         List<Account> toupdateaccounts=new List<Account>();
             List<Account> updatedlist=new List<Account>();
          for(Contact c: conlist){
     c.Account.NoContact__c=c.Account.NoContact__c+1;
    updatedlist.add(c.Account);
 }
 update updatedlist;
    if(trigger.isDelete){
      List<Contact> contactstodelete=[SELECT Id,Name,contact.AccountId,Contact.Account.NoContact__c FROM Contact WHERE Id      IN:trigger.old];
      for(Contact deletedcontact:contactstodelete){
       deletedcontact.Account.NoContact__c=deletedcontact.Account.NoContact__c-1;
           toupdateaccounts.add(deletedcontact.Account); 
        }
       update toupdateaccounts;
    }
}
I want to search a specific account record when i enter a record name  and click search button?  i was written the following code. While compliling the code there is no errors but when i click search button in visualforce page the following query exception throws.
System.QueryException: unexpected token: 'Name'
Error is in expression '{!queryData}' in component <apex:commandButton> in page soqldynamic: Class.DynamicSOQL.queryData: line 24, column 1
Class.DynamicSOQL.queryData: line 24, column 1
my class:
public class DynamicSOQL {
    public string accName{set;get;}
    public string accIndustry{set;get;}
    public List<Account>a{set;get;}
    public void queryData(){
        if(a!=null)
            a.clear();
        string q='select name,Industry from Account WHERE Name=:accName';
        if(accName!=''&&accName!=null&&accIndustry!=''&&accIndustry!=null){
            q=q+'where Name=\''+accName+'\'and Industry=\''+accIndustry+'\'';
        }
        else {
            if(accName!=''&&accName!=null){
           q=q+'where Name=\''+accName+'\''; 
        }
            else{
                if(accIndustry!=''&&accIndustry!=null){
            q=q+'where industry=\''+accIndustry+'\'';
            
        }
            }
            
        }
        a=database.query(q);
    }
    
    }
visualforce page:
<apex:page controller="DynamicSOQL" showHeader="true" sidebar="false">
    <apex:form >
        <apex:pageBlock title="Account Data">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="submit" action="{!queryData}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                   Enter Name: <apex:inputText title="Enter Name" value="{!accName}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                Enter Industry:<apex:inputText title="Enter Industry" value="{!accIndustry}"/>
                    </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
        <apex:pageBlock title="Account Records" rendered="{! !ISNULL(a)}">
        <apex:pageBlockTable value="{!a}" var="b">
            <apex:column value="{!b.Name}"/>
            <apex:column value="{!b.industry}"/>
            </apex:pageBlockTable>
            </apex:pageBlock>
    </apex:form>
</apex:page>
can any one help me what is the mistake that i have made in the code