• Rahul Kumar 652
  • NEWBIE
  • 30 Points
  • Member since 2020


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
I try to query the records using parent-child SOQL in test method  but i get the child reocrds for each parent in reverse order , if the query returns more than one parent records .
But if it return a single parent record than the child records are in proper order.

I attach the example code below , please go through it . 
@IsTest static void test(){
        List<Class__c> cList = new List<Class__c>();
        Class__c classRecord1 = new Class__c(Board__c = 'Bihar',Fee__c = 100, MaxSize__c = 4);
        Class__c classRecord2 = new Class__c(Board__c = 'Bihar',Fee__c = 1000, MaxSize__c = 5);
        cList.add(classRecord1);
        cList.add(classRecord2);
        insert cList;

        List<Student__c> studentList = new List<Student__c>();

        for(Integer i = 0; i < 4; i++){
            Student__c studentData1 = new Student__c(First_Name__c = 'Test Name '+ i + ' c0', LastName__c = 'LastName' + i, Sex__c = 'Female',Class__c = cList[0].Id);

            Student__c studentData2 = new Student__c(First_Name__c = 'Test Name '+ i + ' c1', LastName__c = 'LastName' + i, Sex__c = 'Female',Class__c = cList[1].Id);

            studentList.add(studentData1);
            studentList.add(studentData2);
        }

        insert studentList;

        Class__c output = [SELECT MaxSize__c, Fee__c, (SELECT First_Name__c FROM Students__r) FROM Class__c LIMIT 1];
        System.debug('Single record from output ' + output.Students__r);

        List<Class__c> outputList = [SELECT MaxSize__c, Fee__c, (SELECT First_Name__c FROM Students__r) FROM Class__c];
        System.debug('Single record from list of outputs '+ outputList[0].Students__r);
    }
The output for both debug are : 
      For 1st debug  :   Single record from output (Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTrAAK, First_Name__c=Test Name 0 c0}, Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTtAAK, First_Name__c=Test Name 1 c0}, Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTvAAK, First_Name__c=Test Name 2 c0}, Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTxAAK, First_Name__c=Test Name 3 c0})

For 2nd Debug :     Single record from list of outputs (Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTxAAK, First_Name__c=Test Name 3 c0}, Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTvAAK, First_Name__c=Test Name 2 c0}, Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTtAAK, First_Name__c=Test Name 1 c0}, Student__c:{Class__c=a062x0000023FrkAAE, Id=a052x000003JrTrAAK, First_Name__c=Test Name 0 c0})

You can see that the output of 1st debug gives student records in proper order as they are inserted , but output of 2nd debug givess student records in reverse order as they are inserted. 

I want to know why this happens . 

Thanks in advance
​​​​​​​
I just play with aura component  and get confused that when the recordupdated attribute of force:recordData calls the js action function .
I read in the documentation that recordupdated attribute calls the js function when the it finds the records changes , but i  use a alert in js function  to debug when the recordupdated attribute calls the action in js , and i find that the recordupdated attribute calls the js function as :
1.) when the page loads
2.) when i try to edit but save without any changes 
3.) when i edit the record 
So i want to know that if recordupdated attribute calls the js action only when the records changes  than why it calls the action in js when i save the record without any changes (as mention in point 2 above)
I am able to fire an event even without using aura:registerEvent tag. In which scenarios do we need to use this tag? 
Is it useful ?
I want to do pagination on two page block in VF page using custom controller which required the different records for same object . But when i try to make two standardSetController for same object and use it in two different page block than the pagination does not work properly.
When i try to debug the rerender (getter method) ,the debug calls twice once with older data and other with new data , i am confused why the getter method calls twice on debug .
Also i used rendered in two page block tags and the rendered have a condition on same getter method i.e if size of return list from getter method  is greater than 0 than one page block is rendered and is equal to 0 than other page block is rendered, so i also use debug there but it calls  getter method once in any one page block but according to me it should calls the getter method in both of the page block to check the condition .
I attached my vf page code here : 
<apex:page Controller="ShoppingCartController">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>Shopping Ecommerce</title>
        <!-- Import the Design System style sheet -->
        <apex:slds />
    </head>
    <body>
        <apex:form >
            <apex:pageBlock title="Purchase Orders History" id="orders_list">
                <!--
                Filter: 
                <apex:selectList value="{!setConPurchase.filterId}" size="1">
                <apex:selectOptions value="{!setConPurchase.listViewOptions}"/>
                <apex:actionSupport event="onchange" reRender="orders_list"/>
                </apex:selectList>
                 -->
                <!-- Orders List -->
                <apex:pageBlockTable value="{!PurchaseOrders}" var="order">
                    <apex:column value="{! order.Id }"/>
                    <apex:column value="{! order.Order_Price__c }"/>
                    <apex:column value="{! order.Status__c }"/>
                </apex:pageBlockTable>
                
                <apex:outputText value=" Page: {!setConPurchase.PageNumber} of {! CEILING(setConPurchase.ResultSize / setConPurchase.PageSize) }"/>
                <apex:commandButton rendered="{!setConPurchase.hasPrevious}" value="first" action="{!setConPurchase.first}"/>
                <apex:commandButton rendered="{!setConPurchase.hasPrevious}" value="Previous" action="{!setConPurchase.previous}"/>
                <apex:commandButton rendered="{!setConPurchase.hasNext}" value="next" action="{!setConPurchase.next}"/>
                <apex:commandButton rendered="{!setConPurchase.hasNext}" value="last" action="{!setConPurchase.last}"/>
                Records per page:
                <apex:selectList value="{! setConPurchase.Pagesize }" size="1">
                    <apex:selectOption itemValue="5" itemLabel="5"/>
                    <apex:selectOption itemValue="20" itemLabel="20"/>
                    <apex:actionSupport event="onchange" reRender="orders_list"/>
                </apex:selectList>
            </apex:pageBlock>
            <div align="Center">
                <apex:commandButton value="Add New Purchase" action="{!getProductsPanel}" reRender="products_list"/>
            </div>
            <apex:outputPanel id="products_list">
                <apex:pageBlock title="Products" rendered="{!render}">
                    <apex:pageMessages id="errors" />
                    <apex:actionFunction name="searchProduct" action="{!search}" reRender="products_table">
                    </apex:actionFunction>
                    <apex:inputText value="{!searchText}" html-placeholder="Search Products" onkeyup="searchProduct(this.value)" />
                    
                   <!-- 
					<apex:commandButton value="Add To Cart" action="{!getProductsPanel}" reRender="products_list" /> 
                   -->
                    <apex:pageBlock mode="maindetail" id="products_table">
                        <apex:pageBlock rendered="{!If(WrapperProducts.size > 0 ,true,false)}">
					
                            <apex:pageBlockTable value="{!WrapperProducts}" var="wrapperProduct" >
                                <apex:column title="Select Products">
                                    <apex:inputCheckbox value="{!wrapperProduct.selected}"/>
                                </apex:column>
                                <apex:column value="{! wrapperProduct.product.Name}"/>
                                <apex:column value="{! wrapperProduct.product.ProductCode}"/>
                                <apex:column value="{! wrapperProduct.product.Description}"/>
                                <apex:column value="{! wrapperProduct.product.Quantity__c}"/>
                                <apex:column value="{! wrapperProduct.product.Price_Per_Unit__c}"/>
                            </apex:pageBlockTable> 
                    
                        </apex:pageBlock>
                        <apex:pageBlock rendered="{!If(WrapperProducts.size==0 ,true,false)}" title="Search Result">            
                            <apex:outputLabel value="No Result Found"></apex:outputLabel>           
                        </apex:pageBlock>
                    </apex:pageBlock>
					
                    
                    <apex:outputText value=" Page: {!setConProduct.PageNumber} of {! CEILING(setConProduct.ResultSize / setConProduct.PageSize) }"/>
                    <apex:commandButton rendered="{!setConProduct.hasPrevious}" value="first" action="{!setConProduct.first}"/>
                    <apex:commandButton rendered="{!setConProduct.hasPrevious}" value="Previous" action="{!setConProduct.previous}"/>
                    <apex:commandButton rendered="{!setConProduct.hasNext}" value="next" action="{!setConProduct.next}"/>
                    <apex:commandButton rendered="{!setConProduct.hasNext}" value="last" action="{!setConProduct.last}"/>
                    Records per page:
                    <apex:selectList value="{! setConProduct.Pagesize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5"/>
                        <apex:selectOption itemValue="20" itemLabel="20"/>
                        <apex:actionSupport event="onchange" reRender="products_list"/>
                    </apex:selectList>
                    
                </apex:pageBlock>
            </apex:outputPanel>
        </apex:form>
    </body>
</apex:page>


 
I want to do pagination on two page block in VF page using custom controller which required the different records for same object . But when i try to make two standardSetController for same object and use it in two different page block than the pagination does not work properly.
When i try to debug the rerender (getter method) ,the debug calls twice once with older data and other with new data , i am confused why the getter method calls twice on debug .
Also i used rendered in two page block tags and the rendered have a condition on same getter method i.e if size of return list from getter method  is greater than 0 than one page block is rendered and is equal to 0 than other page block is rendered, so i also use debug there but it calls  getter method once in any one page block but according to me it should calls the getter method in both of the page block to check the condition .
I attached my vf page code here : 
<apex:page Controller="ShoppingCartController">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>Shopping Ecommerce</title>
        <!-- Import the Design System style sheet -->
        <apex:slds />
    </head>
    <body>
        <apex:form >
            <apex:pageBlock title="Purchase Orders History" id="orders_list">
                <!--
                Filter: 
                <apex:selectList value="{!setConPurchase.filterId}" size="1">
                <apex:selectOptions value="{!setConPurchase.listViewOptions}"/>
                <apex:actionSupport event="onchange" reRender="orders_list"/>
                </apex:selectList>
                 -->
                <!-- Orders List -->
                <apex:pageBlockTable value="{!PurchaseOrders}" var="order">
                    <apex:column value="{! order.Id }"/>
                    <apex:column value="{! order.Order_Price__c }"/>
                    <apex:column value="{! order.Status__c }"/>
                </apex:pageBlockTable>
                
                <apex:outputText value=" Page: {!setConPurchase.PageNumber} of {! CEILING(setConPurchase.ResultSize / setConPurchase.PageSize) }"/>
                <apex:commandButton rendered="{!setConPurchase.hasPrevious}" value="first" action="{!setConPurchase.first}"/>
                <apex:commandButton rendered="{!setConPurchase.hasPrevious}" value="Previous" action="{!setConPurchase.previous}"/>
                <apex:commandButton rendered="{!setConPurchase.hasNext}" value="next" action="{!setConPurchase.next}"/>
                <apex:commandButton rendered="{!setConPurchase.hasNext}" value="last" action="{!setConPurchase.last}"/>
                Records per page:
                <apex:selectList value="{! setConPurchase.Pagesize }" size="1">
                    <apex:selectOption itemValue="5" itemLabel="5"/>
                    <apex:selectOption itemValue="20" itemLabel="20"/>
                    <apex:actionSupport event="onchange" reRender="orders_list"/>
                </apex:selectList>
            </apex:pageBlock>
            <div align="Center">
                <apex:commandButton value="Add New Purchase" action="{!getProductsPanel}" reRender="products_list"/>
            </div>
            <apex:outputPanel id="products_list">
                <apex:pageBlock title="Products" rendered="{!render}">
                    <apex:pageMessages id="errors" />
                    <apex:actionFunction name="searchProduct" action="{!search}" reRender="products_table">
                    </apex:actionFunction>
                    <apex:inputText value="{!searchText}" html-placeholder="Search Products" onkeyup="searchProduct(this.value)" />
                    
                   <!-- 
					<apex:commandButton value="Add To Cart" action="{!getProductsPanel}" reRender="products_list" /> 
                   -->
                    <apex:pageBlock mode="maindetail" id="products_table">
                        <apex:pageBlock rendered="{!If(WrapperProducts.size > 0 ,true,false)}">
					
                            <apex:pageBlockTable value="{!WrapperProducts}" var="wrapperProduct" >
                                <apex:column title="Select Products">
                                    <apex:inputCheckbox value="{!wrapperProduct.selected}"/>
                                </apex:column>
                                <apex:column value="{! wrapperProduct.product.Name}"/>
                                <apex:column value="{! wrapperProduct.product.ProductCode}"/>
                                <apex:column value="{! wrapperProduct.product.Description}"/>
                                <apex:column value="{! wrapperProduct.product.Quantity__c}"/>
                                <apex:column value="{! wrapperProduct.product.Price_Per_Unit__c}"/>
                            </apex:pageBlockTable> 
                    
                        </apex:pageBlock>
                        <apex:pageBlock rendered="{!If(WrapperProducts.size==0 ,true,false)}" title="Search Result">            
                            <apex:outputLabel value="No Result Found"></apex:outputLabel>           
                        </apex:pageBlock>
                    </apex:pageBlock>
					
                    
                    <apex:outputText value=" Page: {!setConProduct.PageNumber} of {! CEILING(setConProduct.ResultSize / setConProduct.PageSize) }"/>
                    <apex:commandButton rendered="{!setConProduct.hasPrevious}" value="first" action="{!setConProduct.first}"/>
                    <apex:commandButton rendered="{!setConProduct.hasPrevious}" value="Previous" action="{!setConProduct.previous}"/>
                    <apex:commandButton rendered="{!setConProduct.hasNext}" value="next" action="{!setConProduct.next}"/>
                    <apex:commandButton rendered="{!setConProduct.hasNext}" value="last" action="{!setConProduct.last}"/>
                    Records per page:
                    <apex:selectList value="{! setConProduct.Pagesize }" size="1">
                        <apex:selectOption itemValue="5" itemLabel="5"/>
                        <apex:selectOption itemValue="20" itemLabel="20"/>
                        <apex:actionSupport event="onchange" reRender="products_list"/>
                    </apex:selectList>
                    
                </apex:pageBlock>
            </apex:outputPanel>
        </apex:form>
    </body>
</apex:page>


 
I can't pass this challenge Process Design Without Limits Learn About Object Design-Time Limits. I have below error message. Can anypne please help.

Challenge Not yet complete... here's what's wrong: 
Changing the owner of the Account record failed to update the 'Account_Owner_Name_Process__c' field for the Case object . Make sure that the process is correct and that it is activated.https://trailhead.salesforce.com/modules/process-design-without-limits/units/process-design-without-limits-object
Challenge Not yet complete... here's what's wrong:  Changing the owner of the Account record failed to update the 'Account_Owner_Name_Process__c' field for the Case object . Make sure that the process is correct and that it is activated.

I've implemented the Process Builder on Account to update the Case.Account_Owner_Name_Process__c field if Account.OwnerId changes.
The name is correct 'Update Case Account Owner' ( API Name: Update_Case_Account_Owner) and it's active.

My process builder:
Process Builder is Active

Object - Account - fire on changes

Owner is Changed Entry Criteria

Update Related Cases immediate Action