• ZX Cheow
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi there,

Below is my VF page and the controller, the update on the Currency fields are working fine. However, the update on the Date field is not taking effect.

VF Page:
<apex:page standardController="Order" extensions="displayOrderSchedule">
    <apex:form >
        <apex:pageBlock mode="inlineEdit">
            <apex:pageBlockTable value="{!schedule}" var="term">
                
                <apex:column value="{!term.Date1__c}" />
                <apex:column value="{!term.Amount1__c}" />
                <apex:column value="{!term.Approved_Amount1__c}" />
                <apex:column value="{!term.Comments1__c}" />
                
                <apex:column value="{!term.Date2__c}" breakBefore="true"/> 
                <apex:column value="{!term.Amount2__c}" />
                <apex:column value="{!term.Approved_Amount2__c}" />
                <apex:column value="{!term.Comments2__c}" />
                
                <apex:inlineEditSupport event="ondblclick" showOnEdit="update" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> 
                
            </apex:pageBlockTable>
            
            <apex:commandButton id="update" action="{!quicksave}" value="Update Schedule" styleclass="updateButton"/>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>


Controller:
public class displayOrderSchedule{
    
    private final Order viewOrder;
    
    public List<Order_Media_Offering_Schedule__c> schedule {get;set;}
     
    public displayOrderSchedule(ApexPages.StandardController stdController){
    
        this.viewOrder = (Order)stdController.getRecord();
         
        List<Order> orderList = [Select Id, (Select Id From Order.Order_Product_Schedules_del__r)
                                 From Order
                                 Where Id =: viewOrder.Id];
              
        For (Order ord:orderList) {
                
             integer item_count = ord.Order_Product_Schedules_del__r.size();
             system.debug('Item Size = '+ item_count);
        
            For (integer i=0;i<item_count;i++) {
            
                 system.debug('ItemId[' + i +'] = ' + ord.Order_Product_Schedules_del__r[i].Id);
                 
                 schedule = [select Amount1__c, Approved_Amount1__c, Comments1__c,  Date1__c,
                                    Amount2__c, Approved_Amount2__c, Comments2__c,  Date2__c
                             from Order_Media_Offering_Schedule__c 
                             where Id =: ord.Order_Product_Schedules_del__r[i].Id];
                             
                 system.debug('Schedule is '+ Schedule);
                 
            }
        }
    }
    
    public pagereference quicksave() {

    try    {
        update Schedule;
    }
    
    catch(Exception e) {
        System.debug('Exception occurred '+String.valueOf(e));
    }
    
    return NULL;
    
    } 
}


Anyone facing similar issue? I have tested with apex:outputfield and it is working fine, however as this functionality requires to display fields from other object instead of Order, apex:outputfield could not be used. Appreciate your assistance on this.

Thanks,
ZX
Hi there,

Below is my VF page and the controller, the update on the Currency fields are working fine. However, the update on the Date field is not taking effect.

VF Page:
<apex:page standardController="Order" extensions="displayOrderSchedule">
    <apex:form >
        <apex:pageBlock mode="inlineEdit">
            <apex:pageBlockTable value="{!schedule}" var="term">
                
                <apex:column value="{!term.Date1__c}" />
                <apex:column value="{!term.Amount1__c}" />
                <apex:column value="{!term.Approved_Amount1__c}" />
                <apex:column value="{!term.Comments1__c}" />
                
                <apex:column value="{!term.Date2__c}" breakBefore="true"/> 
                <apex:column value="{!term.Amount2__c}" />
                <apex:column value="{!term.Approved_Amount2__c}" />
                <apex:column value="{!term.Comments2__c}" />
                
                <apex:inlineEditSupport event="ondblclick" showOnEdit="update" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/> 
                
            </apex:pageBlockTable>
            
            <apex:commandButton id="update" action="{!quicksave}" value="Update Schedule" styleclass="updateButton"/>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>


Controller:
public class displayOrderSchedule{
    
    private final Order viewOrder;
    
    public List<Order_Media_Offering_Schedule__c> schedule {get;set;}
     
    public displayOrderSchedule(ApexPages.StandardController stdController){
    
        this.viewOrder = (Order)stdController.getRecord();
         
        List<Order> orderList = [Select Id, (Select Id From Order.Order_Product_Schedules_del__r)
                                 From Order
                                 Where Id =: viewOrder.Id];
              
        For (Order ord:orderList) {
                
             integer item_count = ord.Order_Product_Schedules_del__r.size();
             system.debug('Item Size = '+ item_count);
        
            For (integer i=0;i<item_count;i++) {
            
                 system.debug('ItemId[' + i +'] = ' + ord.Order_Product_Schedules_del__r[i].Id);
                 
                 schedule = [select Amount1__c, Approved_Amount1__c, Comments1__c,  Date1__c,
                                    Amount2__c, Approved_Amount2__c, Comments2__c,  Date2__c
                             from Order_Media_Offering_Schedule__c 
                             where Id =: ord.Order_Product_Schedules_del__r[i].Id];
                             
                 system.debug('Schedule is '+ Schedule);
                 
            }
        }
    }
    
    public pagereference quicksave() {

    try    {
        update Schedule;
    }
    
    catch(Exception e) {
        System.debug('Exception occurred '+String.valueOf(e));
    }
    
    return NULL;
    
    } 
}


Anyone facing similar issue? I have tested with apex:outputfield and it is working fine, however as this functionality requires to display fields from other object instead of Order, apex:outputfield could not be used. Appreciate your assistance on this.

Thanks,
ZX
Hello
I am having trouble increading my COde coverage for my Trigger with my Test Class. 
@isTest (SeeAllData = false)
public class TestNewEarlyBuySalesProgram {
    @isTest    
    public static void myTestClass() 
    {
        Account a = new Account();
            a.Name= 'Test SP Account';
            a.Type= 'Dealer / Distributor';
            a.Partner_Type__c = 'Dealer';
            a.Tier__c = 'Stocking Dealer';
            a.Status__c = 'Active';     
            a.RecordTypeId = '012j0000000cfvw';
         insert a;

        Sales_Program__c sp = new Sales_Program__c();
            sp.Name = 'TestSP';
            sp.Record_Processed__c = False;
            sp.JDE_Number__c = '11111';
            sp.Account__c = a.id;
            sp.Current_SBF_Year__c='2016';
            sp.sales_Program_Type__c = 'SBF';
            sp.External_Id__c = '2016_11111';
            sp.Trex_Brand_Exclusive_Percentage__c= 1.0;
            sp.Trex_1_Competitive_Brand_Percentage__c = 2.0;
            sp.Early_Buy_PY_Total__c=0;
            sp.Trex_Exclusive__c = True;
            sp.Trex_1_Competitive_Brand__c = False;
           
        insert sp;     
        
        sp.Early_Buy_PY_Total__c=3456874;
        sp.Record_Processed__c = True;
        update sp; 

        test.startTest();
     
      //   sp.Early_Buy_PY_Total__c=3456874;
       //  sp.Record_Processed__c = True;
      //   update sp;
            
            Sales_Program__c sp1 = new Sales_Program__c();
            sp1.Name = 'TestSP1';
            sp1.Record_Processed__c = false;
            sp1.JDE_Number__c = '11111';
            sp1.Account__c = a.id;
            sp1.Current_SBF_Year__c='2017';
            sp1.sales_Program_Type__c = 'SBF';
            sp1.External_Id__c = '2017_11111';
            sp1.Trex_Brand_Exclusive_Percentage__c= 1.0;
            sp1.Trex_1_Competitive_Brand_Percentage__c = 2.0;
            sp1.Prior_Year_Indirect_Sales__c = 3456874;
            sp1.Trex_Exclusive__c = True;
            sp1.Trex_1_Competitive_Brand__c = False;
     //   update sp1;     
        
      //  test.startTest();
           insert sp1 ; 
        test.stopTest();          
       
    }

}

I have added the trigger below.  The trigger created a new record when a field(Early_Buy_PY_Total) on the original object is update and the field Record_Processed__c = false.  A workflow updates this field to ensure it does not get processes more than once.  Coverage is at a dismall 26% but I am guessing that is because the Test class is not triggering the Apex Trigger.  Any suggestions would be greatl;y appreciated.
Thanks


User-added image
 
I'm getting the following error in a Process Builder rule, and I'm not sure why. The rule fires when a user lookup field on the Account changes. When that field changes, it changes all of the Account's Contacts ownerId to equal the new field value.

Here's the error:
An error occurred at element myRule_1_A1 (FlowRecordUpdate).
    UPDATE --- UPDATE FAILED --- ERRORS : (ALL_OR_NONE_OPERATION_ROLLED_BACK) Record rolled back because not all records were valid and the request was using AllOrNone header --- for SFDC record with ID : 003A000001VHDehIAH, 

    This report lists the elements that the flow interview executed. The report is a beta feature.
    We welcome your feedback on IdeaExchange.

    Flow Details
    Flow Name: Update_Contact_to_Pipeline_Rep
    Type: Workflow
    Version: 1
    Status: Active

    Flow Interview Details
    Interview Label: Update_Contact_to_Pipeline_Rep-1_Account
    Current User: xxUserxx (005A0000005FohB)
    Start time: 3/2/2016 2:24 PM
    Duration: 28 seconds

    How the Interview Started
    Chris Thames (005A0000005FohB) started the flow interview.
    Some of this flow's variables were set when the interview started.
    myVariable_old = 001A0000014JsaDIAS
    myVariable_current = 001A0000014JsaDIAS
    RecursiveCountVariable = 0.00

    ASSIGNMENT: myVariable_waitStartTimeAssignment
    {!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
    Result
    {!myVariable_waitStartTimeVariable} = "3/2/2016 2:24 PM"

    DECISION: isChangedDecision2_myRule_1_Pipeline_Rep_c
    Executed this outcome: isChangedRule_2_myRule_1_Pipeline_Rep_c
    Outcome conditions: and
    1. {!myVariable_old} (001A0000014JsaDIAS) Is null false
    2. {!myVariable_old.Pipeline_Rep__c} (005A0000007DuG5IAK) Does not equal {!myVariable_current.Pipeline_Rep__c} (005A0000005FohBIAS)
    Logic: All conditions must be true (AND)

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

    RECORD UPDATE: myRule_1_A1
    Find all Contact records where:
    AccountId Equals {!myVariable_current.Id} (001A0000014JsaDIAS)
    Update the records’ field values.
    OwnerId = {!myVariable_current.Pipeline_Rep__c} (005A0000005FohBIAS)
    Result
    Failed to update records that meet the filter criteria.

    Error Occurred: UPDATE --- UPDATE FAILED --- ERRORS : (ALL_OR_NONE_OPERATION_ROLLED_BACK) Record rolled back because not all records were valid and the request was using AllOrNone header --- for SFDC record with ID : 003A000001VHDehIAH,

 
  • March 02, 2016
  • Like
  • 0