• Paras Jain
  • NEWBIE
  • 35 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 1
    Likes Given
  • 34
    Questions
  • 19
    Replies
Hi ,
Is there any way to do any field update on Knowledge record , after I do some selection of Data Categories from my knowledge record in lightning mode?
How can i pass chatter feed rich text from Postman and save it into same form in chatter feed comment
<td class="slds-cell-shrink" data-label="Select Row" style="width:8%;border: 1px solid #cecfd5;padding: 1px 2px;text-align: center;">
                                                <div aura:id="tycoon"> 
                                                  <!--  <input type="checkbox" name="{!ntwrk.CheckValStatus}" id="{!ntwrk.nwID}" onclick="{!c.testCall}" checked="{!ntwrk.CheckValStatus}" value="{!ntwrk.state}"/>
                                               --> <ui:inputCheckbox aura:id="abcd" name="{!ntwrk.CheckValStatus}"  change="{!c.testCall}" value="{!ntwrk.state+}"/>
                                                                                                                                
                                                
                                                </div>                                                                                                   
                                                <span class="slds-checkbox--faux"></span>
                                                <span class="slds-assistive-text">Select All</span>
                                            </td>  
JS CTR-->

var networkCheck = document.querySelectorAll('#' + 'abcd' + ' input[type="checkbox"]');                                                                                                                                        
    
var networkCheck = component.getElement().querySelectorAll('#' + 'abcd' + ' input[type="checkbox"]');

both the lines are not working and geting null values in "networkCheck ".
Any help would be really grateful.
why we can not do any DML on other object in Before Insert or before update Trigger
why static variables loose their state in batch class during every execution.
 
<script>
$('#tree').checktree();
</script>
 
global class wpSiteMatchProductComparable implements Comparable{ 
        
 
 Public list<wpSiteMatchProduct> InnerList{get; set;}
   list<wpSiteMatchProduct> ListRequested{get; set;}
   
   Public static String sortOrder {set;get;}
   public static String sortExpression {set;get;}
        
        public wpSiteMatchProductComparable(List<wpSiteMatchProduct> lstAccWr,String sortOrder2 ,String sortExpression2  )
        {
                InnerList = new list<wpSiteMatchProduct >(); 
             //   ListRequested = new list<wpSiteMatchProduct >();
                 InnerList = lstAccWr;
                 
                 sortExpression =sortExpression2 ;
                 sortOrder =sortOrder2 ;     
               system.debug('vvvvvvvvvvvvvvvvvvvv'+ InnerList +'eeeeeeeee'+ sortExpression + sortOrder );
        }           
            
                global Integer compareTo(Object vProp){  
                system.debug('dddddddddddddddddd');
                    wpSiteMatchProduct PropToComp = (wpSiteMatchProduct)vProp;
               system.debug('dddddddddddddddddd'+ InnerList +'qqqqqqqqqqqqq'+ sortExpression + sortOrder );     
                    if(sortExpression == 'zipcodes') {
                      if(sortExpression > (String)PropToComp.zipcodes){
                        return sortOrder.equals('ASC') ? 1 : 0;  
                      }
                      else{  
                        return sortOrder.equals('ASC') ? 0 : 1;
                        }                  
                    }
                    if(sortExpression == 'perOfLives') {
                      if(double.valueof(sortExpression) > (double)PropToComp.perOfLives){
                        return sortOrder.equals('ASC') ? 1 : 0;  
                      }
                      else{  
                        return sortOrder.equals('ASC') ? 0 : 1;
                        }                  
                    }
                    
                    if(sortExpression == 'noOfLives') {
                      if(Integer.valueof(sortExpression) > (Integer)PropToComp.noOfLives){
                        return sortOrder.equals('ASC') ? 1 : 0;  
                      }
                      else{  
                        return sortOrder.equals('ASC') ? 0 : 1;
                        }                  
                    }
                    if(sortExpression == 'fundingType') {
                      if(sortExpression > (String)PropToComp.fundingType){
                        return sortOrder.equals('ASC') ? 1 : 0;  
                      }
                      else{  
                        return sortOrder.equals('ASC') ? 0 : 1;
                        }                  
                    }
                    
                    if(sortExpression == 'product') {
                      if(sortExpression > (String)PropToComp.product){
                        return sortOrder.equals('ASC') ? 1 : 0;  
                      }
                      else{  
                        return sortOrder.equals('ASC') ? 0 : 1;
                        }                  
                    }
                    if(sortExpression == 'network') {
                      if(sortExpression > (String)PropToComp.network){
                        return sortOrder.equals('ASC') ? 1 : 0;  
                      }
                      else{  
                        return sortOrder.equals('ASC') ? 0 : 1;
                        }                  
                    }                       
                    else   
                       return 0;             
               } 
           
            
        }
/*********************************************************************************************************************
* Name               : CPQ_CTRL_CheckOpenOpportunities                                                               *
* Description        : The class performs following functionality:                                                   *
*                      - This class is controller class for CPQ_CTRL_CheckOpenOpportunities_VFP_Opp VisualForce page.*                     
* Created Date       : 04-Dec-2015                                                                                   *
* Created By         : Accenture                                                                                     *
* Last Modified Date :                                                                                               *
* Last Modified By   :                                                                                               *
* -------------------------------------------------------------------------------------------------------------------*
* VERSION     AUTHOR      DATE                                                                                       *
*   1.0 -    Accenture   04-Dec-2015                                                                                 *
**********************************************************************************************************************/
public with sharing class CPQ_CTRL_CheckOpenOpportunities {
    public String accId{get;set;}
    public Opportunity opportunity{get;set;}
    public List<Opportunity> oppList{get;set;}
    public Boolean showAccountPgBlock {set;get;}
    public Boolean showOppListPgBlock {set;get;}    
    public Pagereference pgref;
    public String customLabelRecordTypeOpp = Label.lbl_Opportunity_New_Record;   
    
    /***********************************************************************************************
    * @Description : Controller                                                                    *
    *                This controller class fetches accountId & CustomLabel.                        *
    * @Params      : ApexPages.StandardController                                                  *
    * @Return      :                                                                               *    
    ***********************************************************************************************/
    public CPQ_CTRL_CheckOpenOpportunities(ApexPages.StandardController controller) {
        accId = apexpages.currentpage().getparameters().get('accid');
        opportunity= new Opportunity();
    }

 // Query on Record Type of Opportunity to fetch the RecordTypeId having name 'New'
    RecordType rt = [SELECT Id FROM RecordType where DeveloperName = : customLabelRecordTypeOpp AND sObjectType = 'Opportunity' limit 1];
    
    /****************************************************************************
     * @Description :This method check for the open Opportunities associated to the account .*
     * @Params      : none                                                    *
     * @Return      : pgref                                                  *    
     ****************************************************************************/

    public pagereference checkStageBeforeInsert() {    
        CPQ_UTIL_CommonMethod uHelper = new CPQ_UTIL_CommonMethod();
        oppList = uHelper.checkOpenOpportunities(accId);
    
        pgref = new pagereference('/006/e?retURL=%2F'+ accId +'&accid='+ accId + '&RecordType=' + rt.Id + '&ent=Opportunity');
        pgref.setRedirect(true);
        pgref.getParameters().put('nooverride', '0');

        if (accId != null) {
            showAccountPgBlock = false;
            showOppListPgBlock = true;
            if (oppList.size() > 0){
                return null;
            }else {   
                return pgref;
            }
        } 
        else{    
            showAccountPgBlock = true;
            showOppListPgBlock = false;
            return null;   
        }
    }
    
    /*********************************************************************************************
    *@Description : This method redirect the user to the Origin page *
    *@Params      : AccountId                                                                        *
    *@Return      : pgref                                                             *    
    *********************************************************************************************/  
    public pagereference cancelOpportunity() {    
      if(accId == null){   
          pgref = new pagereference('/006/o');        
      }
      else{
          pgref = new pagereference('/'+accId );    
      }      
        pgref.setRedirect(true);
        pgref.getParameters().put('nooverride', '0'); 
        return pgref;   
    }
    
    
   /**********************************************************************************************
    *@Description : This method returns the List of Open Opportunities                           *
    *@Params      : AccountId                                                                    *
    *@Return      : List of Open Opportunities                                                   *    
    *********************************************************************************************/     
    public pagereference opportunitiesOnAccount() {
        showOppListPgBlock = true;
        CPQ_UTIL_CommonMethod uHelper = new CPQ_UTIL_CommonMethod();
        oppList = uHelper.checkOpenOpportunities(opportunity.AccountId);
        if(oppList.size()==0){
            pgref = new pagereference('/006/e?retURL=%2F006%2Fo&accid=' + opportunity.AccountId + '&RecordType='+rt.Id+'&ent=Opportunity');
            pgref.setRedirect(true);
            pgref.getParameters().put('nooverride', '0');  
            return pgref;            
        }
        else{          
            return null;
        }
    }
    
    
   /*********************************************************************************************
    *@Description : This method is used to continue and create new Opportunity.                                       *
    *@Params      : void                                                                         *
    *@Return      : pgref                                                             *    
    *********************************************************************************************/    
    public pagereference newOpportunity(){   
        if (accId == null) {
            pgref = new pagereference('/006/e?retURL=%2F006%2Fo&accid=' + opportunity.AccountId + '&RecordType='+rt.Id+'&ent=Opportunity');
            pgref.setRedirect(true);
            pgref.getParameters().put('nooverride', '0');
            return pgref;
        } 
        else {
            return pgref;
        }    
    }

// End of Class.

// Test class for this...
@isTest
private class CPQ_CTRL_CheckOpenOpportunitiesTest {
    static testMethod void validateOpenOpportunitiesClass() 
    {

        Account testAccount= TestDataUtil.createAccount();
       /* Test.startTest();
       // Database.DeleteResult result = Database.insert(testAccount, false);
        Test.stopTest();
        */ 
        
        RecordType rt = [SELECT Id FROM RecordType where DeveloperName ='CPQ_New' AND sObjectType = 'Opportunity' limit 1];  
    
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        CPQ_CTRL_CheckOpenOpportunities testAccPlan = new CPQ_CTRL_CheckOpenOpportunities(sc);
        
        PageReference pageRef = Page.CPQ_CTRL_CheckOpenOpportunities_VFP_Opp;
        pageRef.getParameters().put('accId', testAccount.Id);
        pageRef.getParameters().put('RecordType', rt.Id);
        Test.setCurrentPage(pageRef);
        
        testAccPlan.checkStageBeforeInsert();
        testAccPlan.cancelOpportunity();
        testAccPlan.opportunitiesOnAccount();
        testAccPlan.newOpportunity();        
    }
}
How to show unique parent with one child in report...
please tell me i have to create a report such like parent ---> child --> child

but if parent have two child then onlly one time parent shows and one child shows
SELECT Id, AccountId, (SELECT Id,Core__c FROM Properties__r where Core__c !=null ) FROM Contact WHERE Accountid IN : accountIds

This is my Query..Any limit i have to put in inner query....

This is my trigger.......
trigger updateAccCorefrmProperty on Property__c (after insert, after update, after delete) {


      Set<Id> accountIds = new Set<Id> ();                   
      Map<id,List<Property__c>> mpAccProperty = new  Map<id,List<Property__c>>();     
      Set<String>  PropCores= new Set<String>();
      List<Account> accountListToUpdate = new List<Account>();
      List<Account> accountListToUpdate2 = new List<Account>();
      set<id>  contactId= new set<id> ();
      set<id>  accountwithoutProp = new set<id> ();
                
        if(Trigger.IsInsert ) {
            for(Property__c prp: [SELECT Contact__c, core__c, Contact__r.Accountid from Property__c WHERE Id IN : Trigger.new] )
            {
                if(prp.Contact__c!=null && prp.core__c !=null && prp.Contact__r.Accountid !=null)
                accountIds.add(prp.Contact__r.Accountid);
            }
        
        }
        
        if( Trigger.IsUpdate ) {
            for(Property__c prp: Trigger.new )
            {
               if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c); 
            }
            
            for(Property__c prp: Trigger.old)
            {
               if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c); 
            }
            
             for(Contact con: [select id, AccountId from Contact where id in : contactId and AccountId != null])
                accountIds.add(con.Accountid);
       
        }
        
        
        
        if(Trigger.IsDelete ){
            for(Property__c prp :Trigger.old){
                if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c);        
            }

            for(Contact con: [select id, AccountId from Contact where id in : contactId and AccountId != null])
            accountIds.add(con.Accountid);
        }    
   
        for(Contact conT: [SELECT Id, AccountId, (SELECT Id,Core__c FROM Properties__r where Core__c !=null limit 2000) FROM Contact WHERE Accountid IN : accountIds]){
            if(conT.Properties__r != null && conT.Properties__r.Size() > 0) {
                if(mpAccProperty.containskey(cont.AccountId)){
                List<Property__c> lstProperty= mpAccProperty.get(cont.AccountId);
                lstProperty.addall(conT.Properties__r);
                }
                else{
                mpAccProperty.put(cont.AccountId,conT.Properties__r);}  
            }
            system.debug('wwwwwwwconT.Properties__r.Size()www'+conT.Properties__r.Size());
            if( conT.Properties__r.Size() == 0) {  
                accountwithoutProp.add(cont.AccountId);
                system.debug('wwwwwwwwww'+accountwithoutProp);
            } 
        }
        
        for(Id accId: mpAccProperty.keyset()){
            if(accountwithoutProp.contains(accId))
                accountwithoutProp.remove(accid);
        }
        
           
        String new_propCore;
        for(Id accId: mpAccProperty.keyset()){
            new_propCore='';
            PropCores.clear();
            for(Property__c prop: mpAccProperty.get(accId))
            PropCores.add(prop.core__c);

            new_propCore=String.Join(new List<String>(PropCores),',');
            
            if(!String.IsBlank(new_propCore))
            accountListToUpdate.add(new Account(Id=accId,core__c=new_propCore));         

        }
        if(accountwithoutProp!=null && accountwithoutProp.size()>0){
            for(Id accwithoutPropId : accountwithoutProp){
                accountListToUpdate.add(new Account(Id=accwithoutPropId,core__c=''));
            }
        }
        
        
        //if(accountListToUpdate2.size()>0)
        //update accountListToUpdate2;

        if(accountListToUpdate.size()>0)
        update accountListToUpdate;//update Impacted account 
        
        
}



>>>>>>>>>>>>>

ny using batch m updating Properties...and this trigger fires
System.LimitException: Too many SOQL queries: 101
Error is in expression '{!saveclosedwonpage}' in component <apex:commandButton> in page nonapaclosedwonform: Trigger.InvestmentCriteriaUpdate: line 29, column 1

Trigger.InvestmentCriteriaUpdate: line 29, column 1

there are around 11 triggers, as i have checked in debug log, and they fires 3 to 4 times...and which makes SOQL query increasing
Also the workflows are fire as i checked in debug... what approach should i have to folllow to resolve this problem....


I have populates core field value from Property to its related Cntact 's Account ...on Account the field name is Core
trigger updateAccCorefrmProperty2 on Property__c (after insert, after update, after delete) {


      Set<Id> accid = new Set<Id> ();
      Set<Id> conids= new Set<Id> ();
        Set<Id> conids2= new Set<Id> ();
      Map<id,Id> mpConAccIds= new Map<id,Id>();        
      Map<id,List<Contact>> mpConAccIds2= new Map<id,List<Contact>>();        
      Map<id,List<Property__c>> mpConProp = new  Map<id,List<Property__c>>();     
      Set<String>  PropCores= new Set<String>();
      Map<Id,Set<String>> mpCores = new Map<id,Set<String>> ();
      List<Account> acco = new List<Account>();
      set<id>  propids= new set<id> ();
           
    if(Trigger.IsInsert || Trigger.IsUpdate ) {
       for(Property__c prp: [select id,core__c ,Contact__c,Contact__r.Accountid,Contact__r.Account.core__c from Property__c where id in : Trigger.new] )
       {
        if(prp.Contact__c!=null && prp.core__c !=null)
        accid.add(prp.Contact__r.Accountid);
        
        }
       }
 
    if(Trigger.IsDelete ){
     
         for(Property__c prp :Trigger.old){
             if(prp.Contact__c!=null && prp.core__c !=null)
             propids.add(prp.Contact__c);        
         }
         
         for(Contact con: [select id, AccountId from Contact where id in : propids] )
         {  
              
            accid.add(con.Accountid);
         }    
     }    
    
       for(Account acc: [select id,(select id,AccountId from Contacts) from Account where id in : accid]){
       
          mpConAccIds2.put(acc.id,acc.Contacts);
       
              for(Contact con : acc.Contacts){
                  conids.add(con.id);
               }      
       }
       
       
       for(Contact cont: [select id,(select id,Core__c from Properties__r where Core__c !=null) from Contact where id in : conids2]){
       
       if(cont.Properties__r !=null)
           mpConProp.put(cont.id,cont.Properties__r);
           
           }

          
          
           for(id acc: mpConAccIds2.keyset()){
               PropCores.clear();
               for(Contact cons : mpConAccIds2.get(acc) ){
                   for(Property__c prop: mpConProp.get(cons.id) ){
                       if (prop.core__c != null){
                           PropCores.add(prop.core__c);                   
                       }
                    }
                   
                   }    
               
                     mpCores.put(acc,PropCores);           
               
               }
               
      String new_propCore;
       
       for(Account acc : [select id,core__c from Account where id in :mpCores.keyset()]){
           for(String str: mpCores.get(acc.id)){
               if(new_propCore!=null)
                   new_propCore+= ','+str;
               else{
               new_propCore=str;
               }    
           }
               acc.core__c =new_propCore ;
               acco.add(acc);
       }
       
 
       if(acco.size()>0)
       update acco;
        
        

}
Batch and Schedule apex runs Sychorously or Asynchronously?
 
Need help, i am around 6 months experience in development & overall & total 2 year  exp in salesforce and i am not so logical and i am not find when i have to use wrapper, or other things..i am not able to getting the things fast, what i have to do , whether i have to move in admin part. I am very upset and does not find the right pathway   what i have to do ?
I am deploying my Trigger and test classes to Production but i am getting the error  too much soql queries 101....and the test classes that are already in production are failing ... and as i have checked the error lines of Test class the method of class is callling and there is no problem of anywhere of SOQL query.. please explain me what happening?
public with sharing class ABC_ReportController {
    public String abcFilter { get; set; }
    public String reportId { get; set; }
    public Id instanceId { get; set; }
    public Boolean reportIsRunning { get; set; }
    private transient Reports.ReportResults reportResults;
    ABC_ReportId__c settings = ABC_ReportId__c.getInstance();
    String relationshipType = 'A,B,C';
    
    public PageReference runReport() { 
        if (abcFilter != null) {relationshipType = abcFilter;}
        else{relationshipType = 'A,B,C';}
        Reports.ReportMetadata reportMetadata = Reports.ReportManager.describeReport(settings.ID__c).getReportMetadata();
        List<Reports.ReportFilter> filters = reportMetadata.getReportFilters();
        Reports.ReportFilter newFilter = new Reports.ReportFilter();
        Reports.ReportFilter newFilter2 = new Reports.ReportFilter();
        newFilter.setColumn('Activity.Owner.Name');
        newFilter.setOperator('equals');
        newFilter.setValue(userinfo.getName());
        filters.add(newFilter);
        newFilter2.setColumn('Activity.Relationship_Type__c');
        newFilter2.setOperator('equals');
        newFilter2.setValue(relationshipType);
        filters.add(newFilter2);
        reportMetadata.setReportBooleanFilter(settings.filter__c);
        reportMetadata.setReportFilters(filters);
        Reports.ReportInstance reportInstance = Reports.ReportManager.runAsyncReport(settings.ID__c,reportMetadata, true);
        instanceId = reportInstance.getId();
        processInstance(reportInstance);

        return null;
    }

    public PageReference checkForReportResults() {
        Reports.ReportInstance reportInstance = Reports.ReportManager.getReportInstance(instanceId);
        processInstance(reportInstance);

        return null;
    }

    private void processInstance(Reports.ReportInstance reportInstance) {
        reportIsRunning = reportInstance.getStatus() == 'Running' || reportInstance.getStatus() == 'New';
        if (!reportIsRunning) {
            reportResults = reportInstance.getReportResults();
        }
    }

    public Reports.ReportResults getReportResults() {
        return reportResults;
    }
}

>>>>>>>>>>>>>>>>>>>>>Vf  page
<apex:page action="{!runReport}" controller="ABC_ReportController" readOnly="true">
    
    <!-- 
    <script type="text/javascript">
            window.onload = function() {  
                runReport()
            }
    </script>
    -->
    
    <style>
      table.reportResults { 
          width: 100%;
      }
      
      .notfirst:hover {
          background-color: lightgray;
      }
  </style>
    
  <apex:form >

            <apex:selectList value="{!abcFilter}" multiselect="false" size="1">
                <apex:selectOption itemValue="A,B,C" itemLabel="All"/>
                <apex:selectOption itemValue="A" itemLabel="A"/>
                <apex:selectOption itemValue="B" itemLabel="B"/>
                <apex:selectOption itemValue="C" itemLabel="C"/>
            </apex:selectList> 
      
    <apex:actionPoller action="{!checkForReportResults}" id="poller" reRender="reportResults" interval="5" enabled="{!reportIsRunning}" />      
      
      <!--
      <apex:actionFunction id="runReport" action="{!runReport}" name="runReport">
        <apex:param assignTo="{!reportId}" value="00OS0000000qjis" />
      </apex:actionFunction>
      -->
      
      <apex:commandButton action="{!runReport}" reRender="poller,reportResults" value="Refresh">
          <apex:param value="{!abcFilter}" assignTo="{!relationshipType}"  />
      </apex:commandButton>
   
  </apex:form>
 
  <apex:outputPanel id="reportResults" layout="block">
      <apex:outputText value="Running..." rendered="{!reportIsRunning}"/>
      <apex:outputPanel rendered="{!NOT(reportIsRunning)}">
         <table class="reportResults">
           <thead>
               <apex:repeat value="{!reportResults.reportMetadata.detailColumns}" var="colName">
                   <th><apex:outputText value="{!reportResults.reportExtendedMetadata.detailColumnInfo[colName].label}"/></th>
               </apex:repeat>
           </thead>           
             <tbody>
               <apex:repeat value="{!reportResults.factMap['T!T'].rows}" var="row">
                   <apex:variable value="{!1}" var="cellCounter"/> 
                   <tr class = "notfirst">
                        <apex:repeat rows="1" value="{!row.dataCells}" var="cell">                          
                           <td>
                               <apex:outputLink onclick="window.open('../apex/ABC_TaskEdit?id={!cell.value}','','width=700,height=500');return false;">EDIT</apex:outputLink></td>
                         </apex:repeat>
                       
                       <apex:repeat first="1" value="{!row.dataCells}" var="cell">                          
                           <td><apex:outputText escape="false" value="{!IF(cellCounter = 10,'<a target=_blank href=mailto:' + cell.label + '>' + cell.label + '</a>',IF(OR(cellCounter = 3,cellCounter = 4),'<a target=_blank href=../' + cell.value + '>' + cell.label + '</a>',cell.label))}" /></td>
                            <apex:variable var="cellCounter" value="{!cellCounter + 1}"/>
                       </apex:repeat>
                      
                   </tr>
               </apex:repeat>
           </tbody>
         </table>
         
      </apex:outputPanel>

    </apex:outputPanel>

</apex:page>
why static variables loose their state in batch class during every execution.
 
I am deploying my Trigger and test classes to Production but i am getting the error  too much soql queries 101....and the test classes that are already in production are failing ... and as i have checked the error lines of Test class the method of class is callling and there is no problem of anywhere of SOQL query.. please explain me what happening?
why static variables loose their state in batch class during every execution.
 
/*********************************************************************************************************************
* Name               : CPQ_CTRL_CheckOpenOpportunities                                                               *
* Description        : The class performs following functionality:                                                   *
*                      - This class is controller class for CPQ_CTRL_CheckOpenOpportunities_VFP_Opp VisualForce page.*                     
* Created Date       : 04-Dec-2015                                                                                   *
* Created By         : Accenture                                                                                     *
* Last Modified Date :                                                                                               *
* Last Modified By   :                                                                                               *
* -------------------------------------------------------------------------------------------------------------------*
* VERSION     AUTHOR      DATE                                                                                       *
*   1.0 -    Accenture   04-Dec-2015                                                                                 *
**********************************************************************************************************************/
public with sharing class CPQ_CTRL_CheckOpenOpportunities {
    public String accId{get;set;}
    public Opportunity opportunity{get;set;}
    public List<Opportunity> oppList{get;set;}
    public Boolean showAccountPgBlock {set;get;}
    public Boolean showOppListPgBlock {set;get;}    
    public Pagereference pgref;
    public String customLabelRecordTypeOpp = Label.lbl_Opportunity_New_Record;   
    
    /***********************************************************************************************
    * @Description : Controller                                                                    *
    *                This controller class fetches accountId & CustomLabel.                        *
    * @Params      : ApexPages.StandardController                                                  *
    * @Return      :                                                                               *    
    ***********************************************************************************************/
    public CPQ_CTRL_CheckOpenOpportunities(ApexPages.StandardController controller) {
        accId = apexpages.currentpage().getparameters().get('accid');
        opportunity= new Opportunity();
    }

 // Query on Record Type of Opportunity to fetch the RecordTypeId having name 'New'
    RecordType rt = [SELECT Id FROM RecordType where DeveloperName = : customLabelRecordTypeOpp AND sObjectType = 'Opportunity' limit 1];
    
    /****************************************************************************
     * @Description :This method check for the open Opportunities associated to the account .*
     * @Params      : none                                                    *
     * @Return      : pgref                                                  *    
     ****************************************************************************/

    public pagereference checkStageBeforeInsert() {    
        CPQ_UTIL_CommonMethod uHelper = new CPQ_UTIL_CommonMethod();
        oppList = uHelper.checkOpenOpportunities(accId);
    
        pgref = new pagereference('/006/e?retURL=%2F'+ accId +'&accid='+ accId + '&RecordType=' + rt.Id + '&ent=Opportunity');
        pgref.setRedirect(true);
        pgref.getParameters().put('nooverride', '0');

        if (accId != null) {
            showAccountPgBlock = false;
            showOppListPgBlock = true;
            if (oppList.size() > 0){
                return null;
            }else {   
                return pgref;
            }
        } 
        else{    
            showAccountPgBlock = true;
            showOppListPgBlock = false;
            return null;   
        }
    }
    
    /*********************************************************************************************
    *@Description : This method redirect the user to the Origin page *
    *@Params      : AccountId                                                                        *
    *@Return      : pgref                                                             *    
    *********************************************************************************************/  
    public pagereference cancelOpportunity() {    
      if(accId == null){   
          pgref = new pagereference('/006/o');        
      }
      else{
          pgref = new pagereference('/'+accId );    
      }      
        pgref.setRedirect(true);
        pgref.getParameters().put('nooverride', '0'); 
        return pgref;   
    }
    
    
   /**********************************************************************************************
    *@Description : This method returns the List of Open Opportunities                           *
    *@Params      : AccountId                                                                    *
    *@Return      : List of Open Opportunities                                                   *    
    *********************************************************************************************/     
    public pagereference opportunitiesOnAccount() {
        showOppListPgBlock = true;
        CPQ_UTIL_CommonMethod uHelper = new CPQ_UTIL_CommonMethod();
        oppList = uHelper.checkOpenOpportunities(opportunity.AccountId);
        if(oppList.size()==0){
            pgref = new pagereference('/006/e?retURL=%2F006%2Fo&accid=' + opportunity.AccountId + '&RecordType='+rt.Id+'&ent=Opportunity');
            pgref.setRedirect(true);
            pgref.getParameters().put('nooverride', '0');  
            return pgref;            
        }
        else{          
            return null;
        }
    }
    
    
   /*********************************************************************************************
    *@Description : This method is used to continue and create new Opportunity.                                       *
    *@Params      : void                                                                         *
    *@Return      : pgref                                                             *    
    *********************************************************************************************/    
    public pagereference newOpportunity(){   
        if (accId == null) {
            pgref = new pagereference('/006/e?retURL=%2F006%2Fo&accid=' + opportunity.AccountId + '&RecordType='+rt.Id+'&ent=Opportunity');
            pgref.setRedirect(true);
            pgref.getParameters().put('nooverride', '0');
            return pgref;
        } 
        else {
            return pgref;
        }    
    }

// End of Class.

// Test class for this...
@isTest
private class CPQ_CTRL_CheckOpenOpportunitiesTest {
    static testMethod void validateOpenOpportunitiesClass() 
    {

        Account testAccount= TestDataUtil.createAccount();
       /* Test.startTest();
       // Database.DeleteResult result = Database.insert(testAccount, false);
        Test.stopTest();
        */ 
        
        RecordType rt = [SELECT Id FROM RecordType where DeveloperName ='CPQ_New' AND sObjectType = 'Opportunity' limit 1];  
    
        ApexPages.StandardController sc = new ApexPages.StandardController(testAccount);
        CPQ_CTRL_CheckOpenOpportunities testAccPlan = new CPQ_CTRL_CheckOpenOpportunities(sc);
        
        PageReference pageRef = Page.CPQ_CTRL_CheckOpenOpportunities_VFP_Opp;
        pageRef.getParameters().put('accId', testAccount.Id);
        pageRef.getParameters().put('RecordType', rt.Id);
        Test.setCurrentPage(pageRef);
        
        testAccPlan.checkStageBeforeInsert();
        testAccPlan.cancelOpportunity();
        testAccPlan.opportunitiesOnAccount();
        testAccPlan.newOpportunity();        
    }
}
SELECT Id, AccountId, (SELECT Id,Core__c FROM Properties__r where Core__c !=null ) FROM Contact WHERE Accountid IN : accountIds

This is my Query..Any limit i have to put in inner query....

This is my trigger.......
trigger updateAccCorefrmProperty on Property__c (after insert, after update, after delete) {


      Set<Id> accountIds = new Set<Id> ();                   
      Map<id,List<Property__c>> mpAccProperty = new  Map<id,List<Property__c>>();     
      Set<String>  PropCores= new Set<String>();
      List<Account> accountListToUpdate = new List<Account>();
      List<Account> accountListToUpdate2 = new List<Account>();
      set<id>  contactId= new set<id> ();
      set<id>  accountwithoutProp = new set<id> ();
                
        if(Trigger.IsInsert ) {
            for(Property__c prp: [SELECT Contact__c, core__c, Contact__r.Accountid from Property__c WHERE Id IN : Trigger.new] )
            {
                if(prp.Contact__c!=null && prp.core__c !=null && prp.Contact__r.Accountid !=null)
                accountIds.add(prp.Contact__r.Accountid);
            }
        
        }
        
        if( Trigger.IsUpdate ) {
            for(Property__c prp: Trigger.new )
            {
               if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c); 
            }
            
            for(Property__c prp: Trigger.old)
            {
               if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c); 
            }
            
             for(Contact con: [select id, AccountId from Contact where id in : contactId and AccountId != null])
                accountIds.add(con.Accountid);
       
        }
        
        
        
        if(Trigger.IsDelete ){
            for(Property__c prp :Trigger.old){
                if(prp.Contact__c!=null && prp.core__c !=null)
                contactId.add(prp.Contact__c);        
            }

            for(Contact con: [select id, AccountId from Contact where id in : contactId and AccountId != null])
            accountIds.add(con.Accountid);
        }    
   
        for(Contact conT: [SELECT Id, AccountId, (SELECT Id,Core__c FROM Properties__r where Core__c !=null limit 2000) FROM Contact WHERE Accountid IN : accountIds]){
            if(conT.Properties__r != null && conT.Properties__r.Size() > 0) {
                if(mpAccProperty.containskey(cont.AccountId)){
                List<Property__c> lstProperty= mpAccProperty.get(cont.AccountId);
                lstProperty.addall(conT.Properties__r);
                }
                else{
                mpAccProperty.put(cont.AccountId,conT.Properties__r);}  
            }
            system.debug('wwwwwwwconT.Properties__r.Size()www'+conT.Properties__r.Size());
            if( conT.Properties__r.Size() == 0) {  
                accountwithoutProp.add(cont.AccountId);
                system.debug('wwwwwwwwww'+accountwithoutProp);
            } 
        }
        
        for(Id accId: mpAccProperty.keyset()){
            if(accountwithoutProp.contains(accId))
                accountwithoutProp.remove(accid);
        }
        
           
        String new_propCore;
        for(Id accId: mpAccProperty.keyset()){
            new_propCore='';
            PropCores.clear();
            for(Property__c prop: mpAccProperty.get(accId))
            PropCores.add(prop.core__c);

            new_propCore=String.Join(new List<String>(PropCores),',');
            
            if(!String.IsBlank(new_propCore))
            accountListToUpdate.add(new Account(Id=accId,core__c=new_propCore));         

        }
        if(accountwithoutProp!=null && accountwithoutProp.size()>0){
            for(Id accwithoutPropId : accountwithoutProp){
                accountListToUpdate.add(new Account(Id=accwithoutPropId,core__c=''));
            }
        }
        
        
        //if(accountListToUpdate2.size()>0)
        //update accountListToUpdate2;

        if(accountListToUpdate.size()>0)
        update accountListToUpdate;//update Impacted account 
        
        
}



>>>>>>>>>>>>>

ny using batch m updating Properties...and this trigger fires
I have populates core field value from Property to its related Cntact 's Account ...on Account the field name is Core
trigger updateAccCorefrmProperty2 on Property__c (after insert, after update, after delete) {


      Set<Id> accid = new Set<Id> ();
      Set<Id> conids= new Set<Id> ();
        Set<Id> conids2= new Set<Id> ();
      Map<id,Id> mpConAccIds= new Map<id,Id>();        
      Map<id,List<Contact>> mpConAccIds2= new Map<id,List<Contact>>();        
      Map<id,List<Property__c>> mpConProp = new  Map<id,List<Property__c>>();     
      Set<String>  PropCores= new Set<String>();
      Map<Id,Set<String>> mpCores = new Map<id,Set<String>> ();
      List<Account> acco = new List<Account>();
      set<id>  propids= new set<id> ();
           
    if(Trigger.IsInsert || Trigger.IsUpdate ) {
       for(Property__c prp: [select id,core__c ,Contact__c,Contact__r.Accountid,Contact__r.Account.core__c from Property__c where id in : Trigger.new] )
       {
        if(prp.Contact__c!=null && prp.core__c !=null)
        accid.add(prp.Contact__r.Accountid);
        
        }
       }
 
    if(Trigger.IsDelete ){
     
         for(Property__c prp :Trigger.old){
             if(prp.Contact__c!=null && prp.core__c !=null)
             propids.add(prp.Contact__c);        
         }
         
         for(Contact con: [select id, AccountId from Contact where id in : propids] )
         {  
              
            accid.add(con.Accountid);
         }    
     }    
    
       for(Account acc: [select id,(select id,AccountId from Contacts) from Account where id in : accid]){
       
          mpConAccIds2.put(acc.id,acc.Contacts);
       
              for(Contact con : acc.Contacts){
                  conids.add(con.id);
               }      
       }
       
       
       for(Contact cont: [select id,(select id,Core__c from Properties__r where Core__c !=null) from Contact where id in : conids2]){
       
       if(cont.Properties__r !=null)
           mpConProp.put(cont.id,cont.Properties__r);
           
           }

          
          
           for(id acc: mpConAccIds2.keyset()){
               PropCores.clear();
               for(Contact cons : mpConAccIds2.get(acc) ){
                   for(Property__c prop: mpConProp.get(cons.id) ){
                       if (prop.core__c != null){
                           PropCores.add(prop.core__c);                   
                       }
                    }
                   
                   }    
               
                     mpCores.put(acc,PropCores);           
               
               }
               
      String new_propCore;
       
       for(Account acc : [select id,core__c from Account where id in :mpCores.keyset()]){
           for(String str: mpCores.get(acc.id)){
               if(new_propCore!=null)
                   new_propCore+= ','+str;
               else{
               new_propCore=str;
               }    
           }
               acc.core__c =new_propCore ;
               acco.add(acc);
       }
       
 
       if(acco.size()>0)
       update acco;
        
        

}
public with sharing class ABC_ReportController {
    public String abcFilter { get; set; }
    public String reportId { get; set; }
    public Id instanceId { get; set; }
    public Boolean reportIsRunning { get; set; }
    private transient Reports.ReportResults reportResults;
    ABC_ReportId__c settings = ABC_ReportId__c.getInstance();
    String relationshipType = 'A,B,C';
    
    public PageReference runReport() { 
        if (abcFilter != null) {relationshipType = abcFilter;}
        else{relationshipType = 'A,B,C';}
        Reports.ReportMetadata reportMetadata = Reports.ReportManager.describeReport(settings.ID__c).getReportMetadata();
        List<Reports.ReportFilter> filters = reportMetadata.getReportFilters();
        Reports.ReportFilter newFilter = new Reports.ReportFilter();
        Reports.ReportFilter newFilter2 = new Reports.ReportFilter();
        newFilter.setColumn('Activity.Owner.Name');
        newFilter.setOperator('equals');
        newFilter.setValue(userinfo.getName());
        filters.add(newFilter);
        newFilter2.setColumn('Activity.Relationship_Type__c');
        newFilter2.setOperator('equals');
        newFilter2.setValue(relationshipType);
        filters.add(newFilter2);
        reportMetadata.setReportBooleanFilter(settings.filter__c);
        reportMetadata.setReportFilters(filters);
        Reports.ReportInstance reportInstance = Reports.ReportManager.runAsyncReport(settings.ID__c,reportMetadata, true);
        instanceId = reportInstance.getId();
        processInstance(reportInstance);

        return null;
    }

    public PageReference checkForReportResults() {
        Reports.ReportInstance reportInstance = Reports.ReportManager.getReportInstance(instanceId);
        processInstance(reportInstance);

        return null;
    }

    private void processInstance(Reports.ReportInstance reportInstance) {
        reportIsRunning = reportInstance.getStatus() == 'Running' || reportInstance.getStatus() == 'New';
        if (!reportIsRunning) {
            reportResults = reportInstance.getReportResults();
        }
    }

    public Reports.ReportResults getReportResults() {
        return reportResults;
    }
}

>>>>>>>>>>>>>>>>>>>>>Vf  page
<apex:page action="{!runReport}" controller="ABC_ReportController" readOnly="true">
    
    <!-- 
    <script type="text/javascript">
            window.onload = function() {  
                runReport()
            }
    </script>
    -->
    
    <style>
      table.reportResults { 
          width: 100%;
      }
      
      .notfirst:hover {
          background-color: lightgray;
      }
  </style>
    
  <apex:form >

            <apex:selectList value="{!abcFilter}" multiselect="false" size="1">
                <apex:selectOption itemValue="A,B,C" itemLabel="All"/>
                <apex:selectOption itemValue="A" itemLabel="A"/>
                <apex:selectOption itemValue="B" itemLabel="B"/>
                <apex:selectOption itemValue="C" itemLabel="C"/>
            </apex:selectList> 
      
    <apex:actionPoller action="{!checkForReportResults}" id="poller" reRender="reportResults" interval="5" enabled="{!reportIsRunning}" />      
      
      <!--
      <apex:actionFunction id="runReport" action="{!runReport}" name="runReport">
        <apex:param assignTo="{!reportId}" value="00OS0000000qjis" />
      </apex:actionFunction>
      -->
      
      <apex:commandButton action="{!runReport}" reRender="poller,reportResults" value="Refresh">
          <apex:param value="{!abcFilter}" assignTo="{!relationshipType}"  />
      </apex:commandButton>
   
  </apex:form>
 
  <apex:outputPanel id="reportResults" layout="block">
      <apex:outputText value="Running..." rendered="{!reportIsRunning}"/>
      <apex:outputPanel rendered="{!NOT(reportIsRunning)}">
         <table class="reportResults">
           <thead>
               <apex:repeat value="{!reportResults.reportMetadata.detailColumns}" var="colName">
                   <th><apex:outputText value="{!reportResults.reportExtendedMetadata.detailColumnInfo[colName].label}"/></th>
               </apex:repeat>
           </thead>           
             <tbody>
               <apex:repeat value="{!reportResults.factMap['T!T'].rows}" var="row">
                   <apex:variable value="{!1}" var="cellCounter"/> 
                   <tr class = "notfirst">
                        <apex:repeat rows="1" value="{!row.dataCells}" var="cell">                          
                           <td>
                               <apex:outputLink onclick="window.open('../apex/ABC_TaskEdit?id={!cell.value}','','width=700,height=500');return false;">EDIT</apex:outputLink></td>
                         </apex:repeat>
                       
                       <apex:repeat first="1" value="{!row.dataCells}" var="cell">                          
                           <td><apex:outputText escape="false" value="{!IF(cellCounter = 10,'<a target=_blank href=mailto:' + cell.label + '>' + cell.label + '</a>',IF(OR(cellCounter = 3,cellCounter = 4),'<a target=_blank href=../' + cell.value + '>' + cell.label + '</a>',cell.label))}" /></td>
                            <apex:variable var="cellCounter" value="{!cellCounter + 1}"/>
                       </apex:repeat>
                      
                   </tr>
               </apex:repeat>
           </tbody>
         </table>
         
      </apex:outputPanel>

    </apex:outputPanel>

</apex:page>
trigger UpdateSelfLookUpField on npe4__Relationship__c(before insert,before update,after update) {
     npe4__Relationship__c acc,acc1;
     List<npe4__Relationship__c >acc2=new List<npe4__Relationship__c >();
     
     Set<id> act=new set<id>();
     
        if(trigger.isbefore){
            for(npe4__Relationship__c ac: Trigger.new){ 
            acc1=ac;          
                if( ac.npe4__SYSTEM_SystemCreated__c){
                    ac.city__c=ac.CityUpdate__c;
                    ac.Cohort__c=ac.CohertUpdate__c;
                    ac.Programme__c=ac.ProgrammeUpdate__c;
                    ac.Placement_Engagement__c=ac.Placement_engagemen_update__c;
                    ac.Mentor_engagement__c=ac.Mentor_engagement_Update__c;
                    ac.recordtypeid=ac.Record_Type_parent__c; 
                    ac.Organisation__c=ac.Placement_organisation_Update__c;
                    ac.Placement_Opportunity__c=ac.Placement_Opportunity_Update__c;
                   system.debug('@@@@@@@@22222222222'+ac);
              }
           }
       }
       if(trigger.isafter){
           for(npe4__Relationship__c ac1:Trigger.new){
          system.debug('@@@@@@@@>>>>>>>>'+ac1.npe4__SYSTEM_SystemCreated__c);
               if(!ac1.npe4__SYSTEM_SystemCreated__c)
               system.debug('@@@@@@@@11111111'+ac1.npe4__ReciprocalRelationship__c);
                   act.add(ac1.npe4__ReciprocalRelationship__c);
           }  system.debug('@@@@@@@@33333333'+act.size());
              system.debug('@@@@@@@@33333333'+act);
           if(act.size()>0){
               npe4__Relationship__c rl=[Select id,Organisation__c,npe4__Type__c,Type_Update__c from npe4__Relationship__c where id In :act limit 1];
              
               if(rl!=null){
               
                   update rl;
               }
           } 
       }    
       
}


>>>>>>>>>>>>>>>>>>>>>Test class

@isTest

public class UpdateSelfLookUpFieldTest {

    static testmethod void UpdateSelfLookUpFieldTest (){
    
    Account acc=new Account();
    acc.name='test';  
    insert acc;    
     
    Contact con=new Contact();
    con.lastname='test';
    con.firstname='test';
    con.accountid=acc.id;   
    insert con; 
    
    npe4__Relationship__c acr=new npe4__Relationship__c();
    acr.npe4__Contact__c=con.id;
    acr.npe4__Status__c='Current';
    acr.city__c='Paris';
    acr.Cohort__c='2011';
    acr.Programme__c='abc';
    acr.Placement_Engagement__c='123';
    acr.Mentor_engagement__c='1';
    acr.npe4__SYSTEM_SystemCreated__c= false;    
    insert acr;
    
    
    npe4__Relationship__c ac=new npe4__Relationship__c();
    ac.npe4__Contact__c=con.id;
    ac.npe4__Status__c='Current';
    ac.city__c='Paris';
    ac.Cohort__c='2011';
    ac.Programme__c='abc';
    ac.Placement_Engagement__c='123';
    ac.Mentor_engagement__c='1';
    ac.npe4__SYSTEM_SystemCreated__c= false;  
    ac.npe4__ReciprocalRelationship__c= acr.id;   
    insert ac;
    
    npe4__Relationship__c ac2=new npe4__Relationship__c();
    ac2.npe4__Contact__c=con.id;
    ac2.npe4__Status__c='Current';
    ac2.city__c='Paris';
    ac2.Cohort__c='2011';
    ac2.Programme__c='abc';
    ac2.Placement_Engagement__c='123';
    ac2.Mentor_engagement__c='1';
    ac2.npe4__SYSTEM_SystemCreated__c= true; 
    ac2.npe4__ReciprocalRelationship__c= ac.id;   
    insert ac2;
    
    
    npe4__Relationship__c ac3=[Select id,npe4__Status__c,npe4__ReciprocalRelationship__c,npe4__ReciprocalRelationship__r.city__c from npe4__Relationship__c where id=:ac2.id ];
   
   // ac3.npe4__SYSTEM_SystemCreated__c=false;
   //  ac3.npe4__ReciprocalRelationship__c=acr.id;
    //update ac3;
    
    
    
      }

}




>>>>>>>>>>>>>>>value not coming in debug.... system.debug('@@@@@@@@11111111'+ac1.npe4__ReciprocalRelationship__c);
trigger updateAccountNextPotPurDate on Opportunity(after insert, after update) {
    Set < id > Accountset = new Set < id > ();
    List<Account>actListupdate=new List<Account>();
    List<Account>actsList=new List<Account>();
    public Integer numberDaysDue1;
    public Integer numberDaysDue2 = 90000;
    if(Trigger.isInsert || Trigger.isUpdate){
        for(Opportunity opp: Trigger.new){
            if(opp.Accountid!=null){
                Accountset.add(opp.Accountid);
            }                
        }
       actsList=[select id, Next_Potential_Purchase_Date__c, 
                   (select id, AccountId, StageName, CloseDate, Isclosed 
                       from Opportunities
                       where Isclosed=FALSE Order By CloseDate Desc) 
               from Account 
               where id in : Accountset]; 
           for(Account actlst : actsList){
               if(actlst.Opportunities.size()>0){
                   for (Opportunity opp: actlst .Opportunities) {
                       numberDaysDue1 = math.abs(Date.Today().daysBetween(opp.CloseDate));            
                       if (numberDaysDue2 > numberDaysDue1) {
                           numberDaysDue2 = math.abs(numberDaysDue1);
                           actlst.Next_Potential_Purchase_Date__c = opp.Closedate;
                       }
                   }  
                } 
               else{
                    actlst.Next_Potential_Purchase_Date__c =null ;
                 }
             actListupdate.add(actlst );  
           }
           if(actListupdate.size()>0){ update actListupdate;}
     }
     
     if(Trigger.isDelete){
         for(Opportunity opptniy : Trigger.old){
             if(opptniy.Accountid!=null){
                 Accountset.add(opptniy.Accountid);    
             }    
         }   
     }

}
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} 


var myquery = "SELECT Id,recordType.Name FROM Account WHERE Id = '{!Account.Id}' limit 1";
var result = sforce.connection.query(myquery);
var records = result.getArray("records")[0];
var accountrecordtype= ''+records.RecordType.Name;

var result2 = sforce.connection.query("select Id,Name from RecordType where name='"+accountrecordtype+"' and SObjectType='Contact'");
var conRecordType = result2.getArray("records")[0];
var recordType = ''+conRecordType.Id;

window.location = 'https://cs20.salesforce.com/003/e?retURL=%2F{!Account.Id}&accid={!Account.Id}&RecordType='+recordType;
I created a number field that I am trying to populate with the USD amount of a currency field on opportunities. I have tried two methods but still the field display only the currecy thet the opportunity is in...any help is appreciated...

Method 1
trigger convertcurrency on Opportunity (before insert, before update) {
    for(Opportunity o :trigger.new){
        Boolean isChanged = false;
        if(trigger.isUpdate && o.Reporting_Total__c != trigger.oldMap.get(o.Id).Reporting_Total__c){
            isChanged = true;
        {
        Opportunity[] opps = [select convertCurrency(Reporting_Total__c) from Opportunity where Id = :o.Id];
                        o.Reporting_Total_in_USD__c = o.Reporting_Total__c;
                
        }
        }
    }
}

===============================================
Method 2
trigger convertcurrency on Opportunity (before insert, before update) {
    for(Opportunity o :trigger.new){
        Boolean isChanged = false;
        if(trigger.isUpdate && o.Reporting_Total__c != trigger.oldMap.get(o.Id).Reporting_Total__c){
            isChanged = true;
        {
        
        For (AggregateResult[] opp : [select name, SUM(Reporting_Total__c) rt from Opportunity where id = : o.id  group by Name ])
        
        for(AggregateResult ar : opp){
        
                        o.Reporting_Total_in_USD__c = o.Reporting_Total__c;
                                      }
        }
    }
}
}
 
 <a href="javascript:window.open('{!$Page.CommunityAccountLookup}?savePos=Owner', '_blank', 'width=800, height=400');">
<apex:image id="theImage" value="{!$Resource.Lookupicon}" width="20" height="20"/></a></span>

In which when i click on lookup looks like image a child window open, i want  to disable parent window ,when this child window opens..
 
hi My Previous & First buttton is not working correctly.. i am unable to find the problem,....
VF CODE....
<apex:page controller="PicklistPicker_Class1" sidebar="false" showHeader="false">
    <style>

        .previ1{
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: -10px 1px;
            margin: 0;
            padding: 0;
            width: 9px;
            height: 10px;
        }
        .previoff1
        {
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: -10px -10px;
            margin: 0;
            padding: 0;
            width: 9px;
            height: 10px;
        }
        .first1 {
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: 0 1px;
            width: 9px;
            height: 10px;
        }
        .next1 {
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: -17px 1px;
            width: 9px;
            height: 10px;
        }
        .last1{
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: -27px 1px;
            width: 9px;
            height: 10px;
        }
        .nextoff1 {
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: -17px -10px;
            width: 9px;
            height: 10px;
        }
        .lastoff1 {
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: -27px -10px;
            width: 9px;
            height: 10px;
        }
        .firstoff1 {
            background-image: url('{!URLFOR($Resource.paginationArrows)}');
            background-repeat: no-repeat;
            background-position: 0 -10px;
            width: 9px;
            height: 10px;
        }
        
        .pbHeader{
            font-size:14px;
        }
        .pbBody{
            font-size:15px;
        }
        .detailList{
            font-size:14px;
        }
        .bPageTitle{
            border: 1px solid lightgray;
            padding-bottom: 15px;
            background-color: #fafafa;
            margin-left:9%;
            margin-right:9%;
        }
        .pageType {
            font-size: 38px !important;
            margin-left: 12% !important;
            padding-bottom: 20px;
        }
        .mainTitle{
            width: 200%;
        }
        .bPageBlock {
            background-color: white !important;
            font-size:14px;
        }
        .apexp{
            margin-left:9%;
            margin-right:9%;
        }
        .message{
            margin-left:9%;
            margin-right:9%;
        }
</style>

<script>
function doSearch(thisId){
searchServer(thisId.value);
}
</script>


   <apex:form > <div align="right" ><apex:commandLink style="font-weight:bold; text-decoration:none;" action="{!gotosite}" value="Home"/>&nbsp;&nbsp;&nbsp;<apex:commandLink style="font-weight:bold; text-decoration:none;" action="{!blog}" value=" Blog"/>&nbsp;&nbsp;&nbsp;<apex:commandLink style="margin-right:11%; font-weight:bold; text-decoration:none;" action="{!Logout}" value=" Logout"/></div></apex:form>
        <div style="margin-left:9%;"><apex:image url="{!$Resource.GrantSourceLogo}"/></div>
<apex:form >
<apex:actionFunction name="searchServer" action="{!InputTextType}" reRender="pbt1">
        <apex:param name="accName" value="" />
    </apex:actionFunction>
<apex:outputPanel rendered="{!errormsgnew}">
      <script type="text/javascript">
       {
       window.alert("Please sign in");
       window.parent.location.href ="http://testgrant-grantsource.cs16.force.com/apex/UserLoginVF";
      
    }
    </script>
  </apex:outputPanel>
    <apex:actionFunction name="searchServer" action="{!InputTextType}" reRender="pbt1">
        <apex:param name="accName" value="" />
    </apex:actionFunction>
        <apex:pageBlock id="pbs">
          <Table>
              <tr>
                 <td>  Select Field: &nbsp; &nbsp;  
                    <apex:selectList value="{!SelectedField}" multiselect="false" size="1" >
                         <apex:selectOption itemValue="Zip/Postal Code" itemLabel="Zip/Postal Code"  />
                         <apex:selectOption itemValue="Areas of Interest/Expertise" itemLabel="Areas of Interest/Expertise"  />
                     </apex:selectList>
                  </td>
                  <td>
                         &nbsp; &nbsp;             
                     <apex:commandButton value="OK" action="{!shwhide}"  reRender="frm2"/>
                  </td>
              </tr>
          </Table>
       </apex:pageBlock>
       </apex:form>
        <apex:form id="frm2">
        <apex:pageBlock id="pgb2"  rendered="{!bool}">
            <apex:pageBlockSection id="pgbs2">
               <apex:outputPanel rendered="{!ShwBlock}" >
                  Enter Zip Code:&nbsp;&nbsp;&nbsp;
                    <apex:inputText id="ipZip" value="{!putZip}" required="true"/>
               </apex:outputPanel>
               <apex:outputPanel rendered="{!ShwBlock2}">
                    <apex:selectList id="ddlASType" value="{!SelectedAppraisalType}" size="1" >
                        <apex:selectOptions value="{!AppraisalTypeList}" />
                    </apex:selectList>
               </apex:outputPanel>
                  <apex:commandButton value="Click to Search Records" action="{!search}"  status="stat" reRender="frm3"/>
                 </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    <apex:form id="frm3">
    <apex:pageBlock id="pb12">
    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
   &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
   &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
   &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;
   Grant Writer Name: &nbsp; &nbsp;
   <apex:inputText alt="Search for Grant Writer Records" value="{!InputTextType }" onkeyup="doSearch(this)"  id="searchinput"/>
    <apex:outputPanel id="region">
    <apex:pageBlockTable value="{!showworkshop}" var="txt" id="pbt1" >
            <apex:column value="{!txt.Name}"/>
            <apex:column value="{!txt.User__r.Name}"/>
            <apex:column value="{!txt.Email__c}"/>
            <apex:column value="{!txt.Seeking__c}"/>
            <apex:column value="{!txt.Zip_Postal_Code__c}"/>
        </apex:pageBlockTable>
        </apex:outputPanel>
        </apex:pageBlock>
       <apex:pageBlock > <!-- This section is responsible for providing the Pagination -->
       
            <apex:panelGrid rendered="{!hasValues}" columns="4" id="columstyle" style="margin-left: 50%;" >
                <apex:actionSupport event="onclick" reRender="pbt1" />
                  <apex:outputText style="text-decoration: none;color: black;"  rendered="{!!hasPrevious }" ><img src="{!URLFOR($Resource.s)}" class="firstoff1" alt="First Page"/>&nbsp;&nbsp;<img src="{!URLFOR($Resource.s)}" class="previoff1" alt="Previoff"/>Previous</apex:outputText>
                
                <apex:commandLink action="{!first}" style="text-decoration: none;color: black;"  rendered="{!hasPrevious}" status="fetchStatus" reRender="pb12" ><img src="{!URLFOR($Resource.s)}" title="First Page" alt="First Page" class="first1" /></apex:commandlink>
                <apex:commandLink id="quicksave" action="{!previous}" style="text-decoration: none;color: black;"  rendered="{!hasPrevious }" status="fetchStatus" reRender="pb12"><img src="{!URLFOR($Resource.s)}" title="Previous" alt="Previous" class="previ1"/>Previous</apex:commandlink>
                <apex:commandLink action="{!next}" style="text-decoration: none;color: black;" rendered="{!hasNext}" status="fetchStatus" reRender="pb12" >Next<img src="{!URLFOR($Resource.s)}" title="Next" alt="Next" class="next1"/></apex:commandlink>
                <apex:commandLink action="{!last}" style="text-decoration: none;color: black;"   rendered="{!hasNext}" status="fetchStatus" reRender="pb12"><img src="{!URLFOR($Resource.s)}" title="Last Page" alt="Last Page" class="last1"/></apex:commandlink>
                
                <apex:outputText style="text-decoration: none;color: black;"  rendered="{!!hasNext}" >Next <img src="{!URLFOR($Resource.s)}" class="nextoff1" alt="Next"/>&nbsp;&nbsp;<img src="{!URLFOR($Resource.s)}" class="lastoff1" alt="Last Page"/></apex:outputText>
                
                <apex:outputpanel >
                    <apex:actionstatus id="fetchStatus">
                        <apex:facet name="start">
                            <div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb;height: 100%;opacity:0.65;width:100%;">
                                <div class="waitingHolder" style="top: 60%; width: 500px;left:40%;position:fixed;height: 500px;">
                                    <img class="waitingImage" src="{!URLFOR($Resource.Loading)}" title="Please Wait..." />
                                    <span class="waitingDescription">Please Wait...</span>
                                </div>
                            </div>
                        </apex:facet>
                    </apex:actionstatus>
                </apex:outputpanel>
            </apex:panelGrid>  
                
        </apex:pageBlock>
     </apex:form>
 </apex:page>




Please help me solve my problem.my email id is parasjainlucky@gmail.com
 
Hi all,

I was happily humming along writing my Case before insert trigger, but when I wrote my tests, they all failed.  This appears to be due to the fact that Trigger.newMap is coming up null, and I'm trying to use it late in my trigger.  Meanwhile, Trigger.new works just fine.

I added this code to the very beginning of my trigger:

trigger CaseAutocreateContact on Case (before insert) {
      System.debug(Trigger.newMap == null?'Trigger.newMap is null!':'Trigger.newMap is populated.');

And lo and behold when I run my tests I see:

    20081107011750.678:Trigger.CaseAutocreateContact: line 2, column 5: Trigger.newMap is null!

What gives here?  How can Trigger.new be populated but Trigger.newMap be null?  My trigger is using the 14.0 endpoint.

Thanks.
Here's the scenario:
I created a custom object and added some fields to it and put this custom object into the Account layout. So now the Accounts page has a custom related list on it.
I want to display this custom related list on a visualforce page using <apex:relatedList list="###how do i reference the custom related list###"/>
I am using the Account standardController. My question is: how do i reference this custom related list so that I can display it on my visualforce page?
Thanks.