• Mohit Kapoor
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 7
    Replies
Hi I have a requirement where in we have 2 objects call one parent and one child. The child object are related to parent and have a lookup relation between the two. The child records are sequence by a field called Order having values 1,2,3,4,5.

So every parent will have 5 children record. 

My requirement is that when the status of child 1 is complete, the Status of child 2 should become pending, i.e. I want updates between 2 child records but I cannot involve parent record. 

If someone can provide a logic it would be great hep.
Hi, I have a code.
public class sample1
{    
    public List<City_of_NY_Projects__c> acct {get;set;}
    public  sample1()
    {
        acct = [SELECT Name, (SELECT Name,Step__c,Phase__c,Version__c,Stage__c,Predecessor__c,Start_Date__c,End_Date__c,Stage_Duration__c,Stage_Duration_2__c,Duration_On_Hold__c,Actual_End_Date__c,Resource_Name__c FROM City_of_NY_Project_Timeline__r WHERE VF_Criteria__c = 'true') FROM City_of_NY_Projects__c limit 5];

    
    } 
    
    public string editItem {get;set;}

public pageReference editBtn() {
        return null;
}
  
  public pageReference cancelBtn() {
        editItem = null;
        return null;
}
  
  public PageReference saveBtn() {
  
    
      update acct;

                   
            editItem = null;
          
           return null;
}
       
}

I need to update City of NY Timeline record, which is the child record. Any idea how to modify this.
I have a VF page where I am calling list that has all the records present for a specific object. I have made this like a mass update where in a user can update more than one records at a time. The problem is that values are getting messed up as entries are being updated to different records then the one which is intended. 

I have no idea what would be causing this as never before has something like this happened. If I am calling a record and someone is updating in that, how can it overright in another record.
I have a part of code where we are calling in a list and displaying the values on VF page, The code is

public void orderMod() {
        string str = ApexPages.CurrentPage().getParameters().get('strSerialVal');
        system.debug('----------------------------------> ' + str);
        str = str.replace('_[]=c', '__c');            //parse values
        str = str.replace('&', ',');                 //parse values
        system.debug('----------------------------------> ' + str);
       
        String[] stringLst;
        stringLst = str.split(',');
        system.debug('----------------------------------> ' + stringLst);
        listFieldToShow.clear();
       
        //listFieldToShow.add('Name');
       
        for(string i : stringLst)
        {
            listFieldToShow.add(i);
        }  
        system.debug('----------------------------------> QUERY LIST: ' + listFieldToShow);
       
        setupQuery();
        system.debug('----------------------------------> QUERY String: ' + theQuery);
    }

The problem that I am facing is with standard fields. As standard fields do not have __c, those fields are being left out from the displayed list on the VF page.
I have a piece of code involving multiple triggers and apex classes. The new result of this functionality is that when some conditions are met mostly stage change values, then a record is created in related bject so that we can have track of changes for specific fields.

The strange thing that is happening is that when as an admin user we do do testing, only one record is created but when we do the testing using a customer, there are 2 records being created which are duplicate. We have no idea why would a piece of code work differently for different profiles.
<apex:page standardController="BCG_Project__c" extensions="VisualForce_Embedded_Save_Fix" standardStylesheets="false" >
    <style>
    .budgetTable {border-collapse:collapse;font-size: 11px;border:1px solid #000;cursor:default;}
    .budgetTable td {padding:2px;border-left:1px solid #000;border-right:1px solid #000;}
    .budgetTable tr {border-bottom:1px dotted #DDD;}
    .budgetTable input {text-align:right;width:75px;font-size: 11px;}
    .headers {text-align:center;font-weight:bold;border-bottom:1px solid #000 !important;font-size:10px;background-color:#b0d4fc;}
    .total {background-color:#DDD; text-align:right; font-weight:bold; font-size: 13px;}
    .budgetTable th {font-size:12px;}
    .budgetTable tr > td:first-child { 
        text-align:right;
        font-size:11px;
        font-weight:bold;
        width:150px;
    }
    
    .item {text-align:right;}
    .item:hover {background-color:#fefdca;}
    
    .saving {margin-left:100px;position:absolute;float:left;color:red;font-size:14px;font-weight:bold;}
    </style>


    <div class="saving">
        <apex:actionStatus id="test">
           <apex:facet name="start">
           <apex:actionSupport event="onchange" reRender="budgetPanel">
                SAVING
                </apex:actionsupport>
                </apex:facet>
           <apex:facet name="stop">
                
           </apex:facet>
          </apex:actionStatus>
                </div>
        
        <div id="budget">
         <apex:outputPanel id="datePanelContainer">
        <apex:outputPanel id="budgetPanel">
        
            <apex:form id="theForm">     
            
            <center>
            
            <b>Budget Date</b>: &nbsp;  <apex:inputField value="{!BCG_Project__c.Budget_Date__c}" />
                    &nbsp; &nbsp;
            
            <apex:commandButton action="{!save}" value="Save Budget Changes" reRender="datePanelContainer"  status="test" /> 
                    &nbsp; &nbsp; 
            <b>Budget Status</b>:  <apex:selectList value="{!BCG_Project__c.Budget_Status__c}" size="1" multiselect="false" >
                                        <apex:selectOption itemLabel="Pending" itemValue="Pending" />
                                        <apex:selectOption itemLabel="Approved" itemValue="Approved" />                                        
                                    </apex:selectList>
                    &nbsp; &nbsp; 
            <b>Local Currency</b>: <apex:inputField value="{!BCG_Project__c.Local_Currency__c}" />
                                &nbsp; &nbsp; 
            <b>Exchange Rate</b>: <apex:outputField value="{!BCG_Project__c.Exchange_Rate__c}" />
            </center>
                    <br />
                    
                    <table class="budgetTable">
                    <!-- <tr><th></th></tr> -->
                    <tr class="headers">
                        <td>Budget Items</td>
                        <td>EC Approved</td>
                        <td>EC Approved USD</td>
                        <td>Contract Amount</td>
                        <td>Contract % of Approved</td>
                        <td>Approved <br /> Change Order</td>
                        <td>Pending <br /> Change Order</td>
                        <td>Total Cost</td>
                        <td>Total Cost Δ (Prior Month)</td>
                        <td>Total Cost % of Approved</td>
                        <td>Total Invoiced</td>
                        <td>Invoiced % of Approved</td>
                        <td>Add. Budget <br /> Approved</td>                        
                        <td>Total Cost % of Final App. Budget</td>                        
                        </tr>
                    <tr class="item"><td>Design</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Design_EC_Approved_USD__c}" />
                        </td>
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}"/>
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />                        
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Design_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="item"><td>Construction</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Construction_EC_Approved_USD__c}" />
                        </td>
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Construction_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Cost_of_Final_Appd__c}" /> </td>
                         </tr>
                    
                    <tr class="item"><td>Expense <font style="font-size:9px;">(Non-Capex)</font> Items</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}"/>
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}"/>
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Expense_Items_EC_Approved_USD__c}" />
                        </td>                        
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}"/>
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}"/>
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Expense_Items_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Item_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="total"><td>Project Subtotal</td>
                        <td><apex:outputField value="{!BCG_Project__c.EC_Approved_Project_Subtotal__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_EC_Approved_USD__c}" /></td>                        
                        <td><apex:outputField value="{!BCG_Project__c.Contract_Amount_Project_Subtotal__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Contract_of_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_CO_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_CO_Pending__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Total_Cost__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Invoiced__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Invoiced_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Add_Budget_Appd__c}" /> </td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="item"><td>Contingency</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Contingency_EC_Approved_USD__c}" />
                        </td>                        
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Contingency_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="item"><td>IT Build-Out</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.IT_Build_Out_EC_Approved_USD__c}" />
                        </td>                        
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.IT_Build_Out_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="total">
                        <td>Project Total</td>
                        <td><apex:outputField value="{!BCG_Project__c.EC_Approved_Project_Total__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_EC_Approved_USD__c}" /></td>                        
                        <td><apex:outputField value="{!BCG_Project__c.Contract_Amount_Project_Total__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Contract_of_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_CO_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_CO_Pending__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Invoiced__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Invoiced_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Add_Budget_Appd__c}" /> </td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost_of_Final_Appd__c}" /> </td>    
                        
                        </tr>
                    </table>

              </apex:form>
              </apex:outputPanel>
        </apex:outputPanel>
        </div>


</apex:page>

 When I Select Approved from picklist, it does not update the values in output fields. But when I reselect the page without refreshing, it gets the old values back, so the values are there but not updating. But this is working perfectly in salesforce.

Is there a way to pass values/variables into an extension from a VF page on page load(not via reRender OR maybe force reRender on page load)

This would be used to pass controlling variables to a dynamic controller so that we can make a real time updating and dynamic controllers.

I have tried alot but am not able to hit the limits for this code, the code provided above is in the most inert state and this is working, but the huge data calls is failing the soql limits.....

public class TW_Eval_FYB_FYE {

    public TW_Eval_FYB_FYE(ApexPages.StandardController controller) {
        }
        
    public static void Run() {
        list<TW_FY_Summary__c> theSummaries = new list<TW_FY_Summary__c>();
        list<TW_Monthly_Trend__c> theTrendsList  = new list<TW_Monthly_Trend__c>();
        set<TW_Monthly_Trend__c> theTrends  = new set<TW_Monthly_Trend__c>();
        list<TW_FY_Summary__c> updateList = new list<TW_FY_Summary__c>();
      
      date dateToday     = date.today();
      integer currMonth   = dateToday.month();
    string currYear    = string.valueOf(dateToday.year());

    //Take the Today() current month and match it to TW fiscal month
    if( currMonth >= 7 ) { currMonth = currMonth - 6; }
    else          { currMonth = currMonth + 6; }

        theSummaries    = [SELECT 
                                         Id, FYE_SF__c, FYB_SF__c, FYE_Headcount__c, 
                                         FYB_Headcount__c, FYE_Seats__c, FYB_Seats__c,
                                         FYB_All_in_Cost__c, FYE_All_in_Cost__c,
                                         Current_Headcount__c, Current_Seats__c, Fiscal_Year__c 
                                         
                                         FROM TW_FY_Summary__c 
                                         ORDER BY Id ASC ];
        
        theTrendsList    = [SELECT 
                                         Square_Feet__c, Seats__c, Headcount__c, GAAP_Ann_All_in_Cost_US__c, 
                                         TW_FY_Summary__c, MonthVal__c
                                         
                                         FROM TW_Monthly_Trend__c 
                                         WHERE MonthVal__c = 1 
                                           OR MonthVal__c = 12 
                                           OR MonthVal__c = :currMonth 
                                         ORDER BY TW_FY_Summary__c ASC ];
        
        for( TW_Monthly_Trend__c z : theTrendsList )
        { theTrends.add(z);  }
        
        //System.Debug( '-------------------------------------------------------------> TRENDS' + theTrends );
        
            for( TW_FY_Summary__c a : theSummaries )
            {
                
                for( TW_Monthly_Trend__c b : theTrends )
                {
                    while( a.Id == b.TW_FY_Summary__c )
                    {   
                        if( b.MonthVal__c == 1  ) 
                                { 
                                        a.FYB_SF__c = b.Square_Feet__c;
                                        a.FYB_Headcount__c = b.Headcount__c; 
                                        a.FYB_Seats__c = b.Seats__c;
                                        a.FYB_All_in_Cost__c = b.GAAP_Ann_All_in_Cost_US__c;
                                          if( b.MonthVal__c == currMonth && a.Fiscal_Year__c == currYear ) 
                                          {
                                            a.Current_Headcount__c = b.Headcount__c;
                                            a.Current_Seats__c = b.Seats__c;
                                          }
                                     theTrends.remove(b);          
                                }
                        
                        else if( b.MonthVal__c == 12 ) 
                                { 
                                        a.FYE_SF__c = b.Square_Feet__c;
                                        a.FYE_Headcount__c = b.Headcount__c; 
                                        a.FYE_Seats__c = b.Seats__c;
                                        a.FYE_All_in_Cost__c = b.GAAP_Ann_All_in_Cost_US__c;
                                          if( b.MonthVal__c == currMonth && a.Fiscal_Year__c == currYear ) 
                                          {
                                            a.Current_Headcount__c = b.Headcount__c;
                                            a.Current_Seats__c = b.Seats__c;
                                          }
                                        theTrends.remove(b); 
                                }
                                
            else if( b.MonthVal__c == currMonth && a.Fiscal_Year__c == currYear ) 
                                          {
                                            a.Current_Headcount__c = b.Headcount__c;
                                            a.Current_Seats__c = b.Seats__c;
                                            theTrends.remove(b);
                                          }
                                                             
                    }
                
                } //end trend loop
                            
            } //end summary loop
        
        update theSummaries ;
    }
}

 

Hi I have a requirement where in we have 2 objects call one parent and one child. The child object are related to parent and have a lookup relation between the two. The child records are sequence by a field called Order having values 1,2,3,4,5.

So every parent will have 5 children record. 

My requirement is that when the status of child 1 is complete, the Status of child 2 should become pending, i.e. I want updates between 2 child records but I cannot involve parent record. 

If someone can provide a logic it would be great hep.
I have a part of code where we are calling in a list and displaying the values on VF page, The code is

public void orderMod() {
        string str = ApexPages.CurrentPage().getParameters().get('strSerialVal');
        system.debug('----------------------------------> ' + str);
        str = str.replace('_[]=c', '__c');            //parse values
        str = str.replace('&', ',');                 //parse values
        system.debug('----------------------------------> ' + str);
       
        String[] stringLst;
        stringLst = str.split(',');
        system.debug('----------------------------------> ' + stringLst);
        listFieldToShow.clear();
       
        //listFieldToShow.add('Name');
       
        for(string i : stringLst)
        {
            listFieldToShow.add(i);
        }  
        system.debug('----------------------------------> QUERY LIST: ' + listFieldToShow);
       
        setupQuery();
        system.debug('----------------------------------> QUERY String: ' + theQuery);
    }

The problem that I am facing is with standard fields. As standard fields do not have __c, those fields are being left out from the displayed list on the VF page.
I have a piece of code involving multiple triggers and apex classes. The new result of this functionality is that when some conditions are met mostly stage change values, then a record is created in related bject so that we can have track of changes for specific fields.

The strange thing that is happening is that when as an admin user we do do testing, only one record is created but when we do the testing using a customer, there are 2 records being created which are duplicate. We have no idea why would a piece of code work differently for different profiles.
<apex:page standardController="BCG_Project__c" extensions="VisualForce_Embedded_Save_Fix" standardStylesheets="false" >
    <style>
    .budgetTable {border-collapse:collapse;font-size: 11px;border:1px solid #000;cursor:default;}
    .budgetTable td {padding:2px;border-left:1px solid #000;border-right:1px solid #000;}
    .budgetTable tr {border-bottom:1px dotted #DDD;}
    .budgetTable input {text-align:right;width:75px;font-size: 11px;}
    .headers {text-align:center;font-weight:bold;border-bottom:1px solid #000 !important;font-size:10px;background-color:#b0d4fc;}
    .total {background-color:#DDD; text-align:right; font-weight:bold; font-size: 13px;}
    .budgetTable th {font-size:12px;}
    .budgetTable tr > td:first-child { 
        text-align:right;
        font-size:11px;
        font-weight:bold;
        width:150px;
    }
    
    .item {text-align:right;}
    .item:hover {background-color:#fefdca;}
    
    .saving {margin-left:100px;position:absolute;float:left;color:red;font-size:14px;font-weight:bold;}
    </style>


    <div class="saving">
        <apex:actionStatus id="test">
           <apex:facet name="start">
           <apex:actionSupport event="onchange" reRender="budgetPanel">
                SAVING
                </apex:actionsupport>
                </apex:facet>
           <apex:facet name="stop">
                
           </apex:facet>
          </apex:actionStatus>
                </div>
        
        <div id="budget">
         <apex:outputPanel id="datePanelContainer">
        <apex:outputPanel id="budgetPanel">
        
            <apex:form id="theForm">     
            
            <center>
            
            <b>Budget Date</b>: &nbsp;  <apex:inputField value="{!BCG_Project__c.Budget_Date__c}" />
                    &nbsp; &nbsp;
            
            <apex:commandButton action="{!save}" value="Save Budget Changes" reRender="datePanelContainer"  status="test" /> 
                    &nbsp; &nbsp; 
            <b>Budget Status</b>:  <apex:selectList value="{!BCG_Project__c.Budget_Status__c}" size="1" multiselect="false" >
                                        <apex:selectOption itemLabel="Pending" itemValue="Pending" />
                                        <apex:selectOption itemLabel="Approved" itemValue="Approved" />                                        
                                    </apex:selectList>
                    &nbsp; &nbsp; 
            <b>Local Currency</b>: <apex:inputField value="{!BCG_Project__c.Local_Currency__c}" />
                                &nbsp; &nbsp; 
            <b>Exchange Rate</b>: <apex:outputField value="{!BCG_Project__c.Exchange_Rate__c}" />
            </center>
                    <br />
                    
                    <table class="budgetTable">
                    <!-- <tr><th></th></tr> -->
                    <tr class="headers">
                        <td>Budget Items</td>
                        <td>EC Approved</td>
                        <td>EC Approved USD</td>
                        <td>Contract Amount</td>
                        <td>Contract % of Approved</td>
                        <td>Approved <br /> Change Order</td>
                        <td>Pending <br /> Change Order</td>
                        <td>Total Cost</td>
                        <td>Total Cost Δ (Prior Month)</td>
                        <td>Total Cost % of Approved</td>
                        <td>Total Invoiced</td>
                        <td>Invoiced % of Approved</td>
                        <td>Add. Budget <br /> Approved</td>                        
                        <td>Total Cost % of Final App. Budget</td>                        
                        </tr>
                    <tr class="item"><td>Design</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Design_EC_Approved_USD__c}" />
                        </td>
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}"/>
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Design__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />                        
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Design_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Design_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="item"><td>Construction</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Construction_EC_Approved_USD__c}" />
                        </td>
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Construction__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Construction_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Construction_Cost_of_Final_Appd__c}" /> </td>
                         </tr>
                    
                    <tr class="item"><td>Expense <font style="font-size:9px;">(Non-Capex)</font> Items</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}"/>
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}"/>
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Expense_Items_EC_Approved_USD__c}" />
                        </td>                        
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}"/>
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Expense_Items__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}"/>
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Expense_Items_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Item_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Expense_Items_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="total"><td>Project Subtotal</td>
                        <td><apex:outputField value="{!BCG_Project__c.EC_Approved_Project_Subtotal__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_EC_Approved_USD__c}" /></td>                        
                        <td><apex:outputField value="{!BCG_Project__c.Contract_Amount_Project_Subtotal__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Contract_of_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_CO_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_CO_Pending__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Total_Cost__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Invoiced__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Invoiced_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Add_Budget_Appd__c}" /> </td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Subtotal_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="item"><td>Contingency</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Contingency_EC_Approved_USD__c}" />
                        </td>                        
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_Contingency__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.Contingency_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.Contingency_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="item"><td>IT Build-Out</td>
                        <td><apex:inputField value="{!BCG_Project__c.EC_Approved_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.EC_Approved_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.IT_Build_Out_EC_Approved_USD__c}" />
                        </td>                        
                        <td><apex:inputField value="{!BCG_Project__c.Contract_Amount_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Pending'}" />
                            <apex:outputField value="{!BCG_Project__c.Contract_Amount_IT_Buildout__c}" rendered="{!BCG_Project__c.Budget_Status__c == 'Approved'}" />
                        </td>
                        <td><apex:outputField value="{!BCG_Project__c.IT_Build_Out_Contract_of_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_CO_Approved__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_CO_Pending__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Total_Cost__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Total_Invoiced__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Invoiced_of_Appd__c}" /></td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Add_Budget_Appd__c}" /> </td>
                        <td><apex:inputField value="{!BCG_Project__c.IT_Build_Out_Cost_of_Final_Appd__c}" /> </td>
                        </tr>
                    <tr class="total">
                        <td>Project Total</td>
                        <td><apex:outputField value="{!BCG_Project__c.EC_Approved_Project_Total__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_EC_Approved_USD__c}" /></td>                        
                        <td><apex:outputField value="{!BCG_Project__c.Contract_Amount_Project_Total__c}"/></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Contract_of_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_CO_Approved__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_CO_Pending__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost_from_Prior_Month__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Invoiced__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Invoiced_of_Appd__c}" /></td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Add_Budget_Appd__c}" /> </td>
                        <td><apex:outputField value="{!BCG_Project__c.Project_Total_Cost_of_Final_Appd__c}" /> </td>    
                        
                        </tr>
                    </table>

              </apex:form>
              </apex:outputPanel>
        </apex:outputPanel>
        </div>


</apex:page>

 When I Select Approved from picklist, it does not update the values in output fields. But when I reselect the page without refreshing, it gets the old values back, so the values are there but not updating. But this is working perfectly in salesforce.

Is there a way to pass values/variables into an extension from a VF page on page load(not via reRender OR maybe force reRender on page load)

This would be used to pass controlling variables to a dynamic controller so that we can make a real time updating and dynamic controllers.

I have tried alot but am not able to hit the limits for this code, the code provided above is in the most inert state and this is working, but the huge data calls is failing the soql limits.....

public class TW_Eval_FYB_FYE {

    public TW_Eval_FYB_FYE(ApexPages.StandardController controller) {
        }
        
    public static void Run() {
        list<TW_FY_Summary__c> theSummaries = new list<TW_FY_Summary__c>();
        list<TW_Monthly_Trend__c> theTrendsList  = new list<TW_Monthly_Trend__c>();
        set<TW_Monthly_Trend__c> theTrends  = new set<TW_Monthly_Trend__c>();
        list<TW_FY_Summary__c> updateList = new list<TW_FY_Summary__c>();
      
      date dateToday     = date.today();
      integer currMonth   = dateToday.month();
    string currYear    = string.valueOf(dateToday.year());

    //Take the Today() current month and match it to TW fiscal month
    if( currMonth >= 7 ) { currMonth = currMonth - 6; }
    else          { currMonth = currMonth + 6; }

        theSummaries    = [SELECT 
                                         Id, FYE_SF__c, FYB_SF__c, FYE_Headcount__c, 
                                         FYB_Headcount__c, FYE_Seats__c, FYB_Seats__c,
                                         FYB_All_in_Cost__c, FYE_All_in_Cost__c,
                                         Current_Headcount__c, Current_Seats__c, Fiscal_Year__c 
                                         
                                         FROM TW_FY_Summary__c 
                                         ORDER BY Id ASC ];
        
        theTrendsList    = [SELECT 
                                         Square_Feet__c, Seats__c, Headcount__c, GAAP_Ann_All_in_Cost_US__c, 
                                         TW_FY_Summary__c, MonthVal__c
                                         
                                         FROM TW_Monthly_Trend__c 
                                         WHERE MonthVal__c = 1 
                                           OR MonthVal__c = 12 
                                           OR MonthVal__c = :currMonth 
                                         ORDER BY TW_FY_Summary__c ASC ];
        
        for( TW_Monthly_Trend__c z : theTrendsList )
        { theTrends.add(z);  }
        
        //System.Debug( '-------------------------------------------------------------> TRENDS' + theTrends );
        
            for( TW_FY_Summary__c a : theSummaries )
            {
                
                for( TW_Monthly_Trend__c b : theTrends )
                {
                    while( a.Id == b.TW_FY_Summary__c )
                    {   
                        if( b.MonthVal__c == 1  ) 
                                { 
                                        a.FYB_SF__c = b.Square_Feet__c;
                                        a.FYB_Headcount__c = b.Headcount__c; 
                                        a.FYB_Seats__c = b.Seats__c;
                                        a.FYB_All_in_Cost__c = b.GAAP_Ann_All_in_Cost_US__c;
                                          if( b.MonthVal__c == currMonth && a.Fiscal_Year__c == currYear ) 
                                          {
                                            a.Current_Headcount__c = b.Headcount__c;
                                            a.Current_Seats__c = b.Seats__c;
                                          }
                                     theTrends.remove(b);          
                                }
                        
                        else if( b.MonthVal__c == 12 ) 
                                { 
                                        a.FYE_SF__c = b.Square_Feet__c;
                                        a.FYE_Headcount__c = b.Headcount__c; 
                                        a.FYE_Seats__c = b.Seats__c;
                                        a.FYE_All_in_Cost__c = b.GAAP_Ann_All_in_Cost_US__c;
                                          if( b.MonthVal__c == currMonth && a.Fiscal_Year__c == currYear ) 
                                          {
                                            a.Current_Headcount__c = b.Headcount__c;
                                            a.Current_Seats__c = b.Seats__c;
                                          }
                                        theTrends.remove(b); 
                                }
                                
            else if( b.MonthVal__c == currMonth && a.Fiscal_Year__c == currYear ) 
                                          {
                                            a.Current_Headcount__c = b.Headcount__c;
                                            a.Current_Seats__c = b.Seats__c;
                                            theTrends.remove(b);
                                          }
                                                             
                    }
                
                } //end trend loop
                            
            } //end summary loop
        
        update theSummaries ;
    }
}

 

I'm currently writing a Visualforce page that prompts the user to select an object in their org, and then choose a field from that object. I've found a way to compile the list of objects without any trouble, but I'm struggling to compile a list of the fields belonging to that object. When the user selects an object, I store the object name as a string. I can find the fields for a designated object using the code below:

 

Map<String, Schema.SobjectField> M = Schema.SObjectType.Account.fields.getMap();
            
List<Schema.SObjectField> resultList = M.values();

 

However, I can't seem to use that code to display the fields of every object. The object name goes where it says "Account" but when I try using the string name for the object that was selected, it throws me an error message. I can't find a way to reference any object without manually typing the name in. I know I need to either convert the string name to some other sort of data type or come up with a new algorithm altogether.

 

Does any one have any suggestions?