• Prateek Jain 52
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
In apex i trying to take out below for loop inside for loop .
Below Code base is iterating list if Sobject records.
 
for(SObject sObj: listRecords){
      Map<String,Vals> RowsValsItemListMap = new Map<String,Vals>();
      List<Vals> ValsItemList = new List<Vals>();
      
      Map<String, Object> fieldsToValue = sObj.getPopulatedFieldsAsMap();
      system.debug('Value for is: fieldsToValue' +fieldsToValue);
      
      map01.put(sObj, fieldsToValue);
      
      for (String fieldName : fieldsToValue.keySet()){
          system.debug('Value for fieldName is: ' +fieldName);                  
          Vals ValsItem = new Vals();                    
          ValsItem.val = fieldsToValue.get(fieldName);                
          //ValsItem.val = (String)fieldsToValue.get(fieldName);                        
          RowsValsItemListMap.put(fieldName.toLowerCase(), ValsItem);                
      }                         
      
}

Any help will be really appriciated.
Hi All,

I am trying to Setup New Commuity in my Developer Account but After setting up new Community and when i preview it does not work or show "URL No Longer Exists" error, please suggest if anything happened from salesforce end .

I am using system admin profile,
HI All, 

I am trying to write simple batch class in which i have send multiple emails from the finish method of batch class , Please see the below code that i am trying to use: 
 
global class NotifyBatch2 implements Database.Batchable<sObject>, Database.Stateful {

datetime dt = System.now()-1;
public string query = 'select Id, name,Status__c,CreatedDate,Materials_Meeting_Date__c,Materials_Due_Date__c,CreatedBy.Email,Submitter__c,Book_Coverage__c,Notes__c,Materials_Request_Organization__c from MR_Product__c where Status__c=\'Pending Submission\'';

//Here i am getting the problem.
public List<Messaging.SingleEmailMessage>  mails = new List<Messaging.SingleEmailMessage>();

global database.querylocator start(Database.BatchableContext BC)
{

    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, Sobject[] scope)
{ 


  //
    EmailTemplate emailTemplate = [select Id, Body  from EmailTemplate where DeveloperName = 'BOOK_REQUEST_Template'];

    for (MR_Product__c  item : (List<MR_Product__c>)scope) {
        
    
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
             string MatDueDate = string.valueOfGmt(item.Materials_Due_Date__c);
             string MatMeetingDate = string.valueOfGmt(item.Materials_Meeting_Date__c);      
                    
                    string body = emailTemplate.body;
                    
                    body  = body.replace('{!MR_Product__c.Submitter__c}', item.Submitter__c);
                    body  = body.replace('{!MR_Product__c.Materials_Request_Organization__c}', item.Materials_Request_Organization__c);
                    body  = body.replace('{!MR_Product__c.Materials_Due_Date__c}', MatDueDate );
                    body  = body.replace('{!MR_Product__c.Materials_Meeting_Date__c}', MatMeetingDate);
                    
                    if(item.Notes__c!=null && item.Notes__c!=''){
                    body  = body.replace('{!MR_Product__c.Notes__c}', item.Notes__c);
                    }
                     if(item.Book_Coverage__c!=null && item.Book_Coverage__c!=''){
                    body  = body.replace('{!MR_Product__c.Book_Coverage__c}', item.Book_Coverage__c);
                    
                    }

                    email.setToAddresses(new String[] {item.createdby.Email});
                    email.setSaveAsActivity(false);
                    email.setPlainTextBody(body);
                    
                    email.setTemplateId(emailTemplate.Id);
                    system.debug('Checkemails' + email);
					//Here i am getting problem
                    mails.add(email);
            
           Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
       
    }
    
          
}

global void finish(Database.BatchableContext BC) {

    // for sending final emails:
    Messaging.sendEmail(mails);



}


}
Error i am getting : 

First error: Not Serializable: com/salesforce/api/fast/List$$lcom/salesforce/api/Messaging/SingleEmailMessage$$r

I have already tried making it as transient with no sucess, 

All i want is to send Emails for all records "created by user " in finish method i single go, plaese help , thanks


 
Requirement:
Hi all, I have a requirement where i have two table and based 
of the selection of record of one table i need to display 
its corresponding chid record.

Problem:
"
I have Written onchange event on checkbox, On action i calling one method and fecthing the child record of selected record and storing inList,
" But Problem is everytime upon onchange i am not able to clear the list so that it will show the selected record ite in child table.

Please see the sample code as below:

Vf page code :

    <apex:pageBlockTable value="{!CategoryList}" var="cl" style="width:100%" rows="3" id="blocktable1" >
           <apex:column headerValue="Select" colspan="20" width="10%">
           <apex:inputCheckbox style="height:auto;width:auto;"  value="{!cl.Main_Category__c}" html-data-cbType="mainContactCheckbox">
           <apex:actionSupport event="onchange"  action="{!ExpensesListMethod}" onSubmit="checkboxChanged(this)" reRender="outputpanel2">
            <apex:param name="CategoryId" value="{!cl.Id}" assignTo="{!categoryId}"/>    
                   </apex:actionSupport>    
                    </apex:inputCheckbox>
                    </apex:column>
          </apex:pageBlockTable>

Apex Class code : 

public class ExpensesCombo {
        
    public List<Category__c> CategoryList {get; set;}
    public List<Expenses_Card__c> ExpensesList {get; set;}
    public List<Expenses_Detail__c> ExpensesDetailList {get; set;}
    public Id categoryId {get; set;}
    public Boolean Maincategory {get; set;}

    public Id expensesCardId {get; set;}
        
    public ExpensesCombo(){
        CategoryList = [Select id, name, Address__c,Main_Category__c from Category__c];
        

         ExpensesList = new List<Expenses_Card__c>(); 
         ExpensesList.clear();
                      
    }
    
//Method which is causing the problem and not clearing the list values.
    public void ExpensesListMethod(){
    system.debug('Value for categoryId is22: ' +categoryId);
     system.debug('Value for mainCategory2 ' +Maincategory );
            
//trying clearing the List here
            if (ExpensesList!=null || !ExpensesList.ISEmpty()){
            System.debug('insideList');
            ExpensesList= new List<Expenses_Card__c>();
            ExpensesList.clear();
            }
    
    // trying creating the new instance for fresh values
    ExpensesList= new List<Expenses_Card__c>();
 
    ExpensesList = [Select id, name, Total_Amount_Paid__c, Balance_Due__c, Description__c, Account_Number__c from Expenses_Card__c 
                        where Category__c = :categoryId order by Balance_Due__c desc];    
                        
                        System.debug('CheckList1111' + ExpensesList  );    
                        
                      }
}

Note: Main problem is not able to clear List Upon onchange event on apex:PageBlocktable.

Need Help Badly on this, please let me know what i am exactly missing here., thanks



 
HI All, 

I am trying to write simple batch class in which i have send multiple emails from the finish method of batch class , Please see the below code that i am trying to use: 
 
global class NotifyBatch2 implements Database.Batchable<sObject>, Database.Stateful {

datetime dt = System.now()-1;
public string query = 'select Id, name,Status__c,CreatedDate,Materials_Meeting_Date__c,Materials_Due_Date__c,CreatedBy.Email,Submitter__c,Book_Coverage__c,Notes__c,Materials_Request_Organization__c from MR_Product__c where Status__c=\'Pending Submission\'';

//Here i am getting the problem.
public List<Messaging.SingleEmailMessage>  mails = new List<Messaging.SingleEmailMessage>();

global database.querylocator start(Database.BatchableContext BC)
{

    return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, Sobject[] scope)
{ 


  //
    EmailTemplate emailTemplate = [select Id, Body  from EmailTemplate where DeveloperName = 'BOOK_REQUEST_Template'];

    for (MR_Product__c  item : (List<MR_Product__c>)scope) {
        
    
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
             string MatDueDate = string.valueOfGmt(item.Materials_Due_Date__c);
             string MatMeetingDate = string.valueOfGmt(item.Materials_Meeting_Date__c);      
                    
                    string body = emailTemplate.body;
                    
                    body  = body.replace('{!MR_Product__c.Submitter__c}', item.Submitter__c);
                    body  = body.replace('{!MR_Product__c.Materials_Request_Organization__c}', item.Materials_Request_Organization__c);
                    body  = body.replace('{!MR_Product__c.Materials_Due_Date__c}', MatDueDate );
                    body  = body.replace('{!MR_Product__c.Materials_Meeting_Date__c}', MatMeetingDate);
                    
                    if(item.Notes__c!=null && item.Notes__c!=''){
                    body  = body.replace('{!MR_Product__c.Notes__c}', item.Notes__c);
                    }
                     if(item.Book_Coverage__c!=null && item.Book_Coverage__c!=''){
                    body  = body.replace('{!MR_Product__c.Book_Coverage__c}', item.Book_Coverage__c);
                    
                    }

                    email.setToAddresses(new String[] {item.createdby.Email});
                    email.setSaveAsActivity(false);
                    email.setPlainTextBody(body);
                    
                    email.setTemplateId(emailTemplate.Id);
                    system.debug('Checkemails' + email);
					//Here i am getting problem
                    mails.add(email);
            
           Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
       
    }
    
          
}

global void finish(Database.BatchableContext BC) {

    // for sending final emails:
    Messaging.sendEmail(mails);



}


}
Error i am getting : 

First error: Not Serializable: com/salesforce/api/fast/List$$lcom/salesforce/api/Messaging/SingleEmailMessage$$r

I have already tried making it as transient with no sucess, 

All i want is to send Emails for all records "created by user " in finish method i single go, plaese help , thanks


 
Hi All , 

I have requirment where i need to display the dynamic table in lightning based on the Object , fileds paased from the Components and display it in vf page.

Please see the code that i am trying here:
===Application====
<aura:application access="GLOBAL" extends="ltng:outApp"    >
 <c:PMD_LightningHomepage object="Opportunity" fields="Id" limit="5" tableId="table1"/>
      <aura:dependency resource="c:PMD_LightningHomepage "  /> 
 </aura:application>

===Component==

<aura:component controller="controller" implements="force:appHostable,flexipage:availableForAllPageTypes">
    <ltng:require styles="/resource/SDLC212/assets/styles/salesforce-lightning-design-system-vf.min.css" />
    <aura:attribute name="object" type="String" />
    <aura:attribute name="limit" type="String" default="5" />
    <aura:attribute type="sObject[]" name="latestRecords" />
    <aura:attribute name="fields" type="String[]" default="Id,Name" />
    <aura:attribute name="tableId" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">    
        <head>
        </head>    
        <body> 
            <div class="wrapperscoop">                
                <div class="slds-card__header slds-grid">
                    <div class="slds-media slds-mcate">
                        <div class="slds-media__figure">                           
                        </div>
                        <div class="slds-media__body">
                            <h2 class="slds-text-heading--small slds-truncate">Recently Viewed</h2>
                        </div>
                    </div>                   
                </div>
                <div class="slds-card__body">                    
                    <section class="slds-card__body">
                        <div class="slds-scrollable--x">
                            <table class="slds-table slds-table--bordered slds-max-medium-table--stacked-horizontal">
                                <thead>
                                    <tr class="slds-no-hover">
                                        <aura:iteration items="{!v.fields}" var="field" >
                                            <th class="slds-text-heading--label slds-size--1-of-6" scope="col">{!field}</th>
                                        </aura:iteration>
                                    </tr>
                                </thead>
                                <tbody id="{!v.tableId}">
                              </tbody>
                                    
                            </table>
                        </div>
                    </section>
                </div>
            </div>            
        </body>
    </html>
</aura:component>

===Js-controller=====
({
    doInit  : function(component, event, helper) {
        var action = component.get("c.getRecords");
        var fields = component.get("v.fields");  
        var tableId = component.get("v.tableId"); 
        action.setParams({
            ObjectName : component.get("v.object"),
            limits : component.get("v.limit"),
            //alert('Check1' + fields);
            fieldstoget : fields.join()
        });
        
        action.setCallback(this,function(response){
            var delayMillis = 1000;
            var state = response.getState();
            if(state === 'SUCCESS'){
                component.set("v.latestRecords",response.getReturnValue());
                var retRecords = response.getReturnValue();
                retRecords.forEach(function(s) {
                    var tableRow = document.createElement('tr');
                    fields.forEach(function(field){ 
                        var tableData = document.createElement('td');
                        var tableDataNode = document.createTextNode(s[field]);
                        tableData.appendChild(tableDataNode);
                        tableRow.appendChild(tableData);
                    });
                    // alert(tableId);
                    //alert('tableval' + document.getElementById(tableId) );
                    setTimeout(function() {
                       
                        alert(document.getElementById(component.get("{!v.tableId}")));
                   document.getElementById(component.get("{!v.tableId}")).appendChild(tableRow);
                 }, delayMillis);
                    
                });
            }else if (state === "ERROR") {
                console.log('Error');
            }          
        });
       $A.enqueueAction(action);
        
    }
})

But when i try calling it from Vf page its not able to take the div id and reads it null and hence shows below error , can anybody help me on this,thanks..

Error:
This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'appendChild' of null] Callback failed: apex://PMD_DispRecordsController/ACTION$getRecords Failing descriptor: {markup://c:PMD_LightningHomepage}

Please suggest .

Note : This coponnent Works fine when i do not call it from Vf page i.e preview it directly.