• Himanshu sharma 284
  • NEWBIE
  • -3 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    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
​​​​​​​
User-added imageI want to show custom help text on mouse hover to the icon in the column header of the datatable in lwc.
Hi,

I have a table with horizontal and vertical scroll bars and would like to lock the column headers when scrolling in either direction.
 
<lightning:layoutItem size="12" padding="around-small"><b>Work Orders</b>
        <div class="external-events slds-table--header-fixed_container" style="height:20rem;">
            <div class=" slds-scrollable " style="height:100%;">
                <table class="slds-table slds-table_bordered slds-table_cell-buffer slds-table--header-fixed">
                    <thead>
                        <tr>
                            <th scope="col">
                                <div class="slds-cell-fixed">WO#</div>
                            </th>
                            <th  scope="col">
                                <div class="slds-cell-fixed">Account</div>
                            </th>
                            <th scope="col">
                                <div class="slds-cell-fixed">Postcode</div>
                            </th>
                            <th scope="col">
                                <div class="slds-cell-fixed">Status</div>
                            </th>
                            <th scope="col">
                                <div class="slds-cell-fixed" >Subject</div>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <aura:iteration items="{!v.woList}" var="item">
                            <tr>
                                <td>
                                    <div class="{!'fc-event ' + item.className}" 
                                         data-id="{!item.id}"
                                         data-tag="{!item.tag}"
                                         onclick="{!c.handleClick}">{!item.WorkOrderNumber}   
                                    </div>
                                </td>
                                <td> 
                                    <div>{!item.accountName}</div>
                                </td>
                                <td> 
                                    <div>{!item.postcode}</div> 
                                </td>
                                <td> 
                                    <div>{!item.Status}</div>
                                </td>
                                <td>
                                    <div>{!item.Subject}</div>
                                </td>                            
                            </tr>
                        </aura:iteration>
                    </tbody>
                </table>
            </div>
        </div> 
    </lightning:layoutItem

At the moment it's scrolling ok, and when you scroll vertically the headers are fixed, but the column headers do not move when scrolling horizontally. I'm guessing it's because of the slds-cell-fixed, but I'm not sure what to change it to.
Any help would be much appreciated
I am not able to see SenderEmail Field on the User object pagelayout. but i can see SenderEmail on object level , Please help me to what configuration i missed.

Thanks
Vamsikrishna
 
Hi All,
I need to update new fields value for 10 million campaign member records. I have written a batch class for it and it would take around 5000 batches to update all records.

Noticed that each batch is taking around 2 mins to run. Would like to know if there is a way I could optimize below code.

global class batchclass implements Database.Batchable<sObject>,Database.stateful {
    global set<id> allIds=new set<id>();
    set<Id> failIds = new set<Id>();
    global set<id> allFailedId=new set<id>();
    global map<id,string> errormsgMap =  new map<id,String>();
    public List<Exception__c> exceptionLists = new List<Exception__c>();
    global set<id> allSuccessId=new set<id>();
    private String StringQuery;
    public batchclass(String strQuery,set<Id> failedIds) {
        StringQuery = strQuery;
        failIds = failedIds;
    }
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator(StringQuery);
    }
    
    global void execute(Database.BatchableContext BC, List<CampaignMember> scope) {
        List<CampaignMember> updateCampList = New List<CampaignMember>();
        map<string,double> campmatrxMap = new map<string,double>();
        List<Campaign_Member_Status_Matrix__mdt> campMatrixList = [SELECT id,Order__c,MasterLabel FROM Campaign_Member_Status_Matrix__mdt];
        for(Campaign_Member_Status_Matrix__mdt mtrx: campMatrixList){
            campmatrxMap.put(mtrx.MasterLabel,mtrx.Order__c);       
        }
        for(CampaignMember cmpMember: scope){
            cmpMember.CampaignAccountId__c = (cmpMember.type=='contact')?string.valueof(cmpMember.campaignId)+string.valueof(cmpMember.contact.AccountId) : string.valueof(cmpMember.campaignId)+string.valueof(cmpMember.CompanyOrAccount).toLowerCase();
            cmpMember.Status_Priority__c = (campmatrxMap.containsKey(cmpMember.Status)!=NULL)?campmatrxMap.get(cmpMember.Status):0;
            updateCampList.add(cmpMember);
            allIds.add(cmpMember.Id);
        }
        if (!updateCampList.isempty()) {
            Constants.disableCampaignmembertrigger = true;
            database.SaveResult[] myResult=database.update(updateCampList,false);
            Constants.disableCampaignmembertrigger = false;
            for(integer i=0;i<myResult.size();i++){
                if(myResult.get(i).isSuccess()){
                    allSuccessId.add(myResult.get(i).getID());    
                }else{
                    Database.error error =  myResult.get(i).getErrors().get(0);
                    string errMsg = error.getMessage();
                    errormsgMap.put(updateCampList.get(i).id,errMsg);
                }
                
            }
            
        }
    }
    
    global void finish(Database.BatchableContext BC) {
        for(Id ids :allIds){
            if(!allSuccessId.contains(ids)){
                allFailedId.add(ids); 
            }   
        }
        for(Id recrdId : errormsgMap.keyset()){
            Exception__c exe = new Exception__c();
            exe.Exception_Class_Name__c = 'batchclass';
            exe.Exception_Method_Name__c = 'Execute';
            exe.Exception_Details__c = recrdId+': '+errormsgMap.get(recrdId);
            exceptionLists.add(exe);
        }
        if(!exceptionLists.isEmpty()){
            insert exceptionLists;    
        }
        integer successSize = allSuccessId.size();
        integer FailedSize = allFailedId.size();
        String FailedIds = 'SuccessCount'+successSize +'FailedRecordCount'+FailedSize;
    }
    
}
Error Message:
Challenge Not yet complete... here's what's wrong: 
The AccountTab Visualforce page does not include one or both of the following: the apex:slds tag in the page, or the slds-table value in the table.

Hello all. I am working on the new superbadge and getting stuck on Challenge 3 . I have tried several solutions but cannot get the data to display in table format. Here is my code below, my main issue is where to place the table class in realtion to the pageBlockTable.

<apex:page standardStylesheets="false" standardController="Account" recordSetVar="accounts" tabStyle="account" applyBodyTag="false">
    <apex:slds >
        
        <div class="slds-scope">
             
                <apex:pageBlock>
                    
                    <table class="slds-table"> 
                    <apex:pageBlockTable  value="{!accounts}" var="a">
                       
                        <apex:column headerValue="{!$ObjectType.Account.Fields.Name.Label}">
                            <apex:outputLink value="{!URLFOR($Action.Account.View, a.id)}">{!a.name}</apex:outputLink>
                        </apex:column>
                        
                    </apex:pageBlockTable> 
                    </table>
                    
                </apex:pageBlock>
            
        </div>
    </apex:slds>    
</apex:page>