• Sree Salesforce
  • NEWBIE
  • 159 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 109
    Questions
  • 26
    Replies
Here how shall I send parameter from apex class to batch class In this scenario. I have highligted code.where i want to send as a param.
public class DynamicBatchClass {
    public string selectedclass{get;set;}
    public string classname{get;set;}
    public string inputquery{get;set;}
    public DynamicBatchClass(){
       
    }
    public list<selectoption> getclassnameslist ()
    {
        map<string,sobject> instanceMap=new map<string,sobject>();
        list<selectoption> options=new list<selectoption>();
       system.debug('---->>>>-');
         list<ApexClass> ClassNames=new list<ApexClass>();
        options.add(new selectoption('--None--','--None--'));
        ClassNames=[select Id,name,body from ApexClass];
        for(ApexClass ac:ClassNames)
        { 
           if(ac.body.contains('batch')){
           system.debug('-----'+ac.name);
           options.add(new selectoption(ac.Id,ac.name));
           instanceMap.put(ac.name, ac);
           system.debug('--instanceMap--'+instanceMap);
      }
     }
     
   return options;
 }
 
 public void run(){
     system.debug('--selectedclasses--'+selectedclass);
     system.debug('--query-->'+inputquery);
    Type classType = Type.forName(selectedclass);
    Database.Batchable<sobject> instance = (Database.Batchable<sobject>)classType.newInstance();
    Database.executeBatch((Database.Batchable<sObject>)instance, 100);    

  }
}

Any one help me to pass the classname

VF :- <apex:page controller="DynamicBatchClass" showHeader="false" standardStylesheets="false" sidebar="false" docType="html-5.0" applyBodyTag="False" applyHtmlTag="False">    
   <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en" >
    <apex:stylesheet value="{!URLFOR($Resource.SLDS24, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
 <apex:form>
     
      <div class="slds" role="banner">
      <div class="slds-grid">
             <div class="slds-form-element">
  <label class="slds-form-element__label" for="text-input-01">Input Label</label>
  <div class="slds-form-element__control">
    <input type="text" id="text-input-01" class="slds-input" placeholder="Placeholder Text" />
  </div>
</div>
              <div class="slds-text-heading--large">Select Batch Class</div>
             <apex:selectList value="{!selectedclasses}" multiselect="false" size="1" label="Select Batch Class">
                 <apex:selectOptions value="{!classnameslist}"></apex:selectOptions>
             </apex:selectList>
       </div>   
    </div>
    <apex:pageblock >
     
         <apex:pageBlockSection >
             <apex:inputTextArea label="Query"></apex:inputTextArea>
        </apex:pageBlockSection>
     </apex:pageblock>
 </apex:form>
  </html>
</apex:page>
But i unable to pass the string as a class name in Db.executebatch();
public class DynamicBatchClass {
    public string selectedclass{get;set;}
    public string classname{get;set;}
    public string inputquery{get;set;}
    public DynamicBatchClass(){
       
    }
    public list<selectoption> getclassnameslist ()
    {
        map<string,sobject> instanceMap=new map<string,sobject>();
        list<selectoption> options=new list<selectoption>();
       system.debug('---->>>>-');
         list<ApexClass> ClassNames=new list<ApexClass>();
        options.add(new selectoption('--None--','--None--'));
        ClassNames=[select Id,name,body from ApexClass];
        for(ApexClass ac:ClassNames)
        { 
           if(ac.body.contains('batch')){
           system.debug('-----'+ac.name);
           options.add(new selectoption(ac.Id,ac.name));
           instanceMap.put(ac.name, ac);
           system.debug('--instanceMap--'+instanceMap);
      }
     }
     
   return options;
 }
 
 public void run(){
     system.debug('--selectedclasses--'+selectedclass);
     system.debug('--query-->'+inputquery);
    ApexClass newAp = [select id, name from apexclass where id=:selectedclass];
    string s = newap.Name;
    Database.executeBatch(new s() ,50);
  }
}

Any one help me to pass the classname

VF :- <apex:page controller="DynamicBatchClass" showHeader="false" standardStylesheets="false" sidebar="false" docType="html-5.0" applyBodyTag="False" applyHtmlTag="False">    
   <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en" >
    <apex:stylesheet value="{!URLFOR($Resource.SLDS24, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
 <apex:form>
     
      <div class="slds" role="banner">
      <div class="slds-grid">
             <div class="slds-form-element">
  <label class="slds-form-element__label" for="text-input-01">Input Label</label>
  <div class="slds-form-element__control">
    <input type="text" id="text-input-01" class="slds-input" placeholder="Placeholder Text" />
  </div>
</div>
              <div class="slds-text-heading--large">Select Batch Class</div>
             <apex:selectList value="{!selectedclasses}" multiselect="false" size="1" label="Select Batch Class">
                 <apex:selectOptions value="{!classnameslist}"></apex:selectOptions>
             </apex:selectList>
       </div>   
    </div>
    <apex:pageblock >
     
         <apex:pageBlockSection >
             <apex:inputTextArea label="Query"></apex:inputTextArea>
        </apex:pageBlockSection>
     </apex:pageblock>
 </apex:form>
  </html>
</apex:page>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="shiporder">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="orderperson" type="xs:string"/>
      <xs:element name="shipto">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="address" type="xs:string"/>
            <xs:element name="city" type="xs:string"/>
            <xs:element name="country" type="xs:string"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="item" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="note" type="xs:string" minOccurs="0"/>
            <xs:element name="quantity" type="xs:positiveInteger"/>
            <xs:element name="price" type="xs:decimal"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="orderid" type="xs:string" use="required"/>
  </xs:complexType>
</xs:element>

</xs:schema>

On Visulaforce I want to see like this :-
O/p:- 
shiporder
  -->shipto
   .Name
   .Address
   .City
   .Country
--> Item
  .Title
  .Note
  .Quantity
  .Price
 LIke this i want to get from file.
How shall i proceed?

1) is it a parital insert or update  (or) is there any error occurs while doing insertion is it revort back?
2) i have thres lists 
  ->a (parent)
 -->b (child)
 -->c (child)
how it will work when i commit?
can you explain this.
string st='test';
list<sobject> str=database.query('select id,name from account where name like' +'\''+st+'\'');

can anyone explain clearly , How system understand these characters after like
        +'\''+st+'\''
 
User-added image
I need a query , when i query i want to get rectly created records , i.e c3 and c6 contacts only i need.
How shall write query.
Could please hel me
When i Ran test Class I Am getting the issue.
Class.System.JSON.deserializeUntyped: line 11, column 1
Class.GroupAndEntitiesExtension.getEntityData: line 182, column 1
Class.GroupAndEntitiesExtension_Test.GroupAndEntitiesExtension_Test: line 77, column 1

Apex Class:- 

global class GroupAndEntitiesExtension {
    
    //variables
    public String eListData{get;set;}
    public String eListDataEdit{get;set;}
    public string groupId{get;set;}
    public string inputvalue{get;set;}
    public list<WrpperGroups> groupsearchlist{get;set;}
    public boolean showtable{get;set;}
    public Integer rowIndex {get;set;}
    public list<odm__C> deleteOdmrecords;
    public list<capital__C> deleteCapitalrecords;
    public list<ownership__c> deleteOwnershiprecords;
    public odm__c od;
    public capital__C captl;
    public Ownership__c ownrs;
    Public Service_Request__c serviceRequest{get;set;}
    public List<ODM__c> ODM {get;set;} 
    public List<Capital__c> capital {get;set;}
    public List<Ownership__c> Ownership {get;set;}
    public string groupsearchname{get;set;}
    public Boolean isGuestUser{get;set;}
    public String operation {get;set;}
    public String title {get;set;}
    public string conid{get;set;}
    public Id caseId;    
    public Boolean showFeed{get;set;}// to simulate standard feed functionality
    public transient Cookie feedCookie{get;set;}// to simulate standard feed functionality
    public Boolean feedView{get;set;} //Need to be removched
    Case caseRecord;
    public String serviceReqAction {get;set;}
    public List<SelectOption> servReqActionList{get;set;}
    public string groupaccountId{get;set;}
    List<entity__c> entitylist;
    public List<String> alphabets{get;set;}
    List<WrpperGroups> Tempwrapperlist= new List<WrpperGroups>();
    public List<Service_Request_Entity_Junction__c > entityViewtable{get;set;}
    public Boolean showGroupAndEntitiyTable{get;set;}
    public Boolean showGridError{get;set;}
    public String jsonEntityResponse{get;set;}
    public List<WrpperEntities> jsonEntitiesSelectAll;
    
    public GroupAndEntitiesExtension(ApexPages.StandardController stdcontroller){ 
        entitylist = new List<entity__c>();
        eListData =''; eListDataEdit = '';
        entityViewtable=new List<Service_Request_Entity_Junction__c>(); 
        od = new ODM__c();
        captl = new capital__C();
        ownrs = new Ownership__c();
        ODM = new List<ODM__c>();
        Capital = new List<Capital__c>();
        Ownership = new List<Ownership__c>();
        deleteOdmrecords=new List<odm__C>();
        deleteCapitalrecords=new List<capital__c>();
        deleteOwnershiprecords=new List<ownership__c>();
        groupsearchlist= new List<WrpperGroups>();
        alphabets=new List<string>{'All','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};  
            isGuestUser = (UserInfo.getName() == Label.Guest_User);
        showGridError = false;
        system.debug('=========================operation ======='+ApexPages.currentPage().getParameters().get('operation'));
        // logic for new service request
        if(ApexPages.currentPage().getParameters().get('id') == null){   
            operation = 'New';
            serviceRequest = new Service_Request__c();
            BillingFormHelper.readPageParameters(ApexPages.currentPage().getParameters(),serviceRequest);
            serviceRequest.Recordtypeid = Utils.fetchRecordTypeId('Service_Request__c','Entity Update');            
            if(isGuestUser){
                title = 'New Service Request';
            }
            else{
                caseId = ApexPages.currentPage().getParameters().get('caseId');
                caseRecord = [Select Id,Status,caseNumber from Case where Id =: caseId];
                title = 'New Service Request for Case# '+caseRecord.CaseNumber;
            }
            congrouplist();  
            showtable=true;
            showGroupAndEntitiyTable = false;
        }
        // logic for existing service request
        if(ApexPages.currentPage().getParameters().get('id') != null){   
            operation = 'View';
            showtable = false;
            serviceRequest = (Service_Request__c)stdController.getRecord();
            // to simulate standard feed functionality
            conid =serviceRequest.Contact__c;
            system.debug('==========--conid--==================================='+conid);
            feedCookie = ApexPages.currentPage().getCookies().get('ShowFeedView');
            if (feedCookie == null)
                feedCookie = new Cookie('ShowFeedView','False',null,-1,false);
            else 
                showFeed = (feedCookie.getValue() != 'False' );       
            entitytableView();
            showGroupAndEntitiyTable = false;
            fetchRelatedListData(serviceRequest.Id);
        }        
        if(ApexPages.currentPage().getParameters().get('operation') == 'Edit'){
            showGroupAndEntitiyTable = true;
            showtable = false;
            congrouplist(); 
            showEditScreen();        
        }
    }
    
    public List<Service_Request_Entity_Junction__c > entitytableView(){
        entityViewtable= [select Entity__r.name,Entity__r.Entity_ID__c,Entity__r.Entity_Party_ID__c from Service_Request_Entity_Junction__c where ServiceRequest__c=:serviceRequest.id];
        system.debug('--junlist--'+entityViewtable);
        return entityViewtable;    
    } 
    
    public void handleViewScreen(){
        System.debug('In handleViewScreen===='+ApexPages.currentPage().getParameters().get('id'));
        if(ApexPages.currentPage().getParameters().get('id') != null){  
            System.debug('serviceRequest.Id==='+serviceRequest.Id);
            //Code to Update the checkboxes if records are added from Related List.
            List<ODM__c> odmListAdded = new List<ODM__c>();
            odmListAdded = [select Id from ODM__c where Service_Request__c =: serviceRequest.Id];
            System.debug('odmListAdded===='+odmListAdded);
            if(odmListAdded.size()>0){
                serviceRequest.ODM__c = true;
            }else{
                serviceRequest.ODM__c = false;
            }
            List<Capital__c> capitalListAdded = new List<Capital__c>();
            capitalListAdded = [select Id from Capital__c where Service_Request__c =: serviceRequest.Id];
            if(capitalListAdded.size()>0){
                serviceRequest.Capital__c = true;
            }else{
                serviceRequest.Capital__c = false;
            }
            List<Ownership__c> ownerListAdded = new List<Ownership__c>();
            ownerListAdded = [select Id from Ownership__c where Service_Request__c =: serviceRequest.Id];
            if(ownerListAdded.size()>0){
                serviceRequest.Ownership__c = true;
            }else{
                serviceRequest.Ownership__c = false;
            }
            System.debug('serviceRequest===='+serviceRequest);
            update serviceRequest;
        }
    }
    
    @RemoteAction
    global static string getEntityData(String eSearchId){
        //To Do:
        // Create List of Wrapper
        // Get Results 
        // Iterate Through getting Next tag
        // Parse into List of Wrapper()
        // Run call for next result set
        // Add to List of Wrapper
        List<WrpperEntities> groupentitieslist=new list<WrpperEntities>();
        String bodyresp = '';
        system.debug('--groupaccountId--'+eSearchId);
        groupentitieslist.clear();  
        if(eSearchId=='' || eSearchId==Null){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please select group'));  
        }
        if(eSearchId!='' && eSearchId!=Null){
            List<WrpperEntities> eList = new List<WrpperEntities>();
            Boolean firstRun = true;
            Boolean hasNext = true;
            String nextUrl = '';
            Long startingTime = DateTime.now().getTime(); //track how long this takes
            while(hasNext){
                Long nowTime = DateTime.now().getTime();
                if(nowTime - startingTime > 110000){
                    WrpperEntities we = new WrpperEntities('00','The request for this groups list of entities took an extended amount of time. Please retry getting the entities. If this request continues to fail please contact Support.','','','');
                    groupentitieslist.add(we);
                    break;
                }
                if(firstRun){
                    bodyresp = APICalloutUtils.getEntityInfo(eSearchId);
                    system.debug('--==bodyresp'+bodyresp);
                    firstRun = false;
                }
                else{
                    bodyresp = APICalloutUtils.getNextEntityInfo(nextURL, eSearchId);
                    system.debug('--bodyresp'+bodyresp);
                }    
                
                Map<String,Object> jsonStub = new Map<String,Object>();
                jsonStub = (Map<String,Object>)JSON.deserializeUntyped(bodyresp);
                List<Object> entityJSONList = new List<Object>();
                entityJSONList = (List<Object>)jsonStub.get('entities');
                List<Object> linkObjectList = new List<Object>();
                linkObjectList = (List<Object>)jsonStub.get('links');
                
                Boolean nextURLFound = false;
                if(linkObjectList != null){
                    for(Object o : linkObjectList){
                        Map<String,Object> linkObjectMap = (Map<String,Object>)o;
                        List<Object> urlNameList = (List<Object>)linkObjectMap.get('rel');
                        String urlName = (String)urlNameList[0];
                        if(urlName == 'next'){
                            nextUrl = (String)linkObjectMap.get('href');
                            nextURLFound = true;
                            system.debug('NEXT URL Link FOR API CALL OUT TO ENTITIES: ==>>' + nextUrl);
                        }
                    }
                }
                if(nextURLFound == false)
                    nextUrl = '';
                
                if(Test.isRunningTest())
                    hasNext = false;
                
                if(nextUrl == ''){
                    hasNext = false;
                }
                system.debug('--body--'+bodyresp);
                System.debug('entityJSONList===='+entityJSONList);
                if(entityJSONList != null){
                    for(Object o : entityJSONList){
                        Map<String,Object> entityMap = (Map<String,Object>)o;
                        for(String s : entityMap.keySet()){
                            if(s == 'properties'){
                                Map<String,Object> propertiesMap = (Map<String,Object>)entityMap.get(s);
                                WrpperEntities we = new WrpperEntities(String.valueOf((Integer)propertiesMap.get('id')),(String)propertiesMap.get('entityName'),(String)propertiesMap.get('cscIndicator'), (String)propertiesMap.get('entityLegacyId'),(String)propertiesMap.get('cscStatus'));
                                groupentitieslist.add(we);
                            }
                        }
                    }
                }
                
            }
        }
        String jsonResult = json.serialize(groupentitieslist);
        system.debug('--------Complete Entity JSON Respose--------'+jsonResult);
        return jsonResult;
    }
    
    
Am I  create list on  The attribute Like that
I am getting this error.
User-added image

When i  hide the attrbute on component. This alert is not showing.
Class:

public class DynamicAccountController {
@AuraEnabled
public static List<DynamicAccountController.AccountWrapper> GetAccountNames()
{
    List<DynamicAccountController.AccountWrapper> accountlist =new List<DynamicAccountController.AccountWrapper>();
    system.debug('--enter--');
    list<account> lstPositions=[select id,name from account limit 10];
    for(account ac:lstPositions)
    {
         
        accountlist.add(new AccountWrapper(ac));
        
    }
    system.debug('--accountlist'+accountlist);
    return accountlist;
}
    public class AccountWrapper{
        @AuraEnabled public account acc{get;set;}
        @AuraEnabled public boolean selected{get;set;}
        
        public AccountWrapper(account accs){
            acc=accs;
            selected=false;
          }
    }}
 
Component:-
<aura:component controller="searchAccountController">
   <ltng:require styles="{! $Resource.SLDS24+ '/assets/styles/salesforce-lightning-design-system.css'}"/>
    <aura:attribute name="wrappers" type="wrapperaccount"> </aura:attribute>
    <aura:attribute name="accounts" type="Account" />
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>
   <aura:attribute name="searchKeyword" description="use for input" type="string" ></aura:attribute>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <div class="slds-m-around--large">
       <form class="slds-form--inline"> 
         <div class="slds-form-element"> 
            <label class="slds-form-element__label" for="Search">Account Search</label>  
              <div class="slds-form-element__control" >
                <ui:inputtext aura:id="searchId" value="{!v.searchKeyword}" placeholder="Type Account Name"  class="slds-input"></ui:inputtext>
              </div>
            </div> 
             <div class="slds-form-element">
                 <button type="Button" onclick="{!c.SearchJS}" class="slds-button slds-button--brand">Search</button>
                 </div>
        </form>   
         <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> ID</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> Name</div>
                    </th>   
                     <th scope="col">
                          <div class="slds-truncate" title="Type">Type</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Industry">Industry</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Phone">Phone</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Fax">Fax</div>
                       </th>
                </tr>
            </thead>
            <tbody>
                 <aura:if isTrue="{!v.Message}">
               <div class="slds-text-color--error"> No Result Found...</div>
            </aura:if>
                <aura:iteration items="{!v.wrappers}" var="Wrap"> 
              <tr>
                  <td>
                     <div class="slds-truncate">{!Wrap.acc.Id}</div>
                  </td>
               <!--  <td>
                     <div class="slds-truncate">{!Wrap.acc.name}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!Wrap.acc.Type}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!Wrap.acc.industry}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!Wrap.acc.Phone}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!Wrap.acc.fax}</div>
                  </td> -->
              </tr>
                </aura:iteration>     
            </tbody>
        </table> 
      </div>     
     
</aura:component>
JS :-
({
    SearchJS : function(component, event, helper) {
        var searchKeyId=component.find("searchId"); 
        var searchKey=component.get('v.searchKeyword');
        alert('==searchKeyword'+searchKey);
        if(searchKey == '' || searchKey == null)
        {
            alert('--enter');
          //  searchKeyId.set("v.errors",[{message: "Enter search Keyword" }]);
             $A.util.addClass(searchKeyId,'errorClassAdd');
            //$A.util.removeClass(searchKeyId,'errorClassRemove');
        }
        else{
             $A.util.addClass(searchKeyId, 'errorClassRemove');
             $A.util.removeClass(searchKeyId, 'errorClassAdd');
            helper.searchHelper(component,event);
        } 
    },
})
Helper :- 
({
    searchHelper: function(component, event) {
        var action = component.get("c.searchmethod");
        alert('====key'+component.get("v.searchKeyword"));
        action.setParams({
            'searchKeyword': component.get("v.searchKeyword")         
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if storeResponse size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                } else {
                    component.set("v.Message", false);
                
                }
                var wrappers=new Array();
                for (var idx=0; idx<storeResponse.length; idx++) {
                   var wrapper = { 'acc' : storeResponse[idx],
                   'selected' : false
                            };
                    
               wrappers.push(wrapper);
                    alert('--wrapper--'+wrappers);
            } 
                 // component.set("v.searchResult", storeResponse);
                   component.set('v.wrappers', wrappers);
                    alert('==='+component.set("v.searchResult", storeResponse));
                
            } 
 
        });
        $A.enqueueAction(action);
 
    },
})

Apex:- 

public class searchAccountController {

 @AuraEnabled
  public static list<account> searchmethod(string searchKeyword)
  {
    system.debug('--enter --'+searchKeyword);
    String searchKey=searchKeyword + '%';
    system.debug('--enter =--'+searchKey);
    list<account> returnList =new list<account>();
    list<account> AccList=[select id,name,type,industry,phone,fax from account where name like: searchKey];
    for(account acc:AccList)
    {
    returnList.add(acc);
       }
    return returnList;
    
  }
    
    public class wrapperaccount{
       
        @AuraEnabled
        public Account acc {get; set;}
        @AuraEnabled
        public Boolean selected {get; set;}
    }
}

I have follwed this link  http://bobbuzzard.blogspot.in/2015/12/lightning-component-wrapper-classes.html

I am getting this error

User-added image
User-added image
<aura:component controller="searchAccountController">
   <ltng:require styles="{! $Resource.SLDS24+ '/assets/styles/salesforce-lightning-design-system.css'}"/>
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>
   <aura:attribute name="searchKeyword" description="use for input" type="string" ></aura:attribute>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <div class="slds-m-around--large">
       <form class="slds-form--inline"> 
         <div class="slds-form-element"> 
            <label class="slds-form-element__label" for="Search">Account Search</label>  
              <div class="slds-form-element__control" >
                <ui:inputtext aura:id="searchId" value="{!v.searchKeyword}" placeholder="Type Account Name" required="true" class="slds-input"></ui:inputtext>
              </div>
            </div> 
             <div class="slds-form-element">
                 <button type="Button" onclick="{!c.Search}" class="slds-button slds-button--brand">Search</button>
                 </div>
        </form>   
        <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> ID</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> Name</div>
                    </th>   
                     <th scope="col">
                          <div class="slds-truncate" title="Type">Type</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Industry">Industry</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Phone">Phone</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Fax">Fax</div>
                       </th>
                </tr>
            </thead>
            <tbody>
            <aura:if isTrue="{!v.Message}">
               <div class="slds-text-color--error"> No Result Found...</div>
            </aura:if>
                <aura:iteration items="{!v.searchResult}" var="acc"> 
              <tr>
                  <td>
                     <div class="slds-truncate">{!acc.Id}</div>
                  </td>
                   <td>
                     <div class="slds-truncate">{!acc.name}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!acc.Type}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!acc.industry}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!acc.Phone}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!acc.fax}</div>
                  </td>
              </tr>
                </aura:iteration>    
            </tbody>
        </table>
      </div>     
     
</aura:component>
 
Component:-
<aura:component controller="searchAccountController">
   <ltng:require styles="{! $Resource.SLDS24+ '/assets/styles/salesforce-lightning-design-system.css'}"/>
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>
   <aura:attribute name="searchKeyword" description="use for input" type="string" ></aura:attribute>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <div class="slds-m-around--large">
       <form class="slds-form--inline"> 
         <div class="slds-form-element"> 
            <label class="slds-form-element__label" for="Search">Account Search</label>  
              <div class="slds-form-element__control" >
                <ui:inputtext aura:id="searchId" value="{!v.searchKeyword}" placeholder="Type Account Name" required="true" class="slds-input"></ui:inputtext>
              </div>
            </div> 
             <div class="slds-form-element">
                 <button type="Button" onclick="{!c.Search}" class="slds-button slds-button--brand">Search</button>
                 </div>
        </form>   
        <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> ID</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> Name</div>
                    </th>   
                     <th scope="col">
                          <div class="slds-truncate" title="Type">Type</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Industry">Industry</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Phone">Phone</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Fax">Fax</div>
                       </th>
                </tr>
            </thead>
            <tbody>
            <aura:if isTrue="{!v.Message}">
               <div class="slds-text-color--error"> No Result Found...</div>
            </aura:if>
                <aura:iteration items="{!v.searchResult}" var="acc"> 
              <tr>
                  <td>
                     <div class="slds-truncate">{!acc.Id}</div>
                  </td>
                   <td>
                     <div class="slds-truncate">{!acc.name}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!acc.Type}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!acc.industry}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!acc.Phone}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!acc.fax}</div>
                  </td>
              </tr>
                </aura:iteration>    
            </tbody>
        </table>
      </div>     
     
</aura:component>

JS Controller :- 

({
    Search : function(component, event, helper) {
        var searchKeyId=component.find("searchId"); 
        var searchKey=component.get('v.searchKeyword');
        alert('==searchKeyword'+searchKey);
        if(searchKey == '' || searchKey == null)
        {
            alert('enter');
            searchKeyId.set("v.errors",[{message: "Enter search Keyword" }]);
        }
        else{
            helper.searchHelper(component,event);
        } 
    },
})

Helper :- 
({
    searchHelper: function(component, event) {
        var action = component.get("c.search");
        alert('====key'+component.get("v.searchKeyword"));
        action.setParams({
            'searchKeyWord': component.get("v.searchKeyword")         
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if storeResponse size is 0 ,display no record found message on screen.
                if (storeResponse.length == 0) {
                    component.set("v.Message", true);
                } else {
                    component.set("v.Message", false);
                
                }
                // set numberOfRecord attribute value with length of return value from server
                //component.set("v.numberOfRecord", storeResponse.length);
                // set searchResult list with return value from server.
                  component.set("v.searchResult", storeResponse);
                    alert('==='+component.set("v.searchResult", storeResponse));
            } 
 
        });
        $A.enqueueAction(action);
 
    },
})

Apex:-
public class searchAccountController {

 @AuraEnabled
  public static list<account> search(string searchKeyword)
  {
    system.debug('--enter --'+searchKeyWord);
    String searchKey=searchKeyword + '%';
    system.debug('--enter =--'+searchKey);
    list<account> returnList =new list<account>();
    list<account> AccList=[select id,name,type,industry,phone,fax from account where name like: searchKey ];
    for(account acc:AccList)
    {
    returnList.add(acc);
    system.debug('--ret list-'+returnList);
    }
    return returnList;
    
  }
}
<aura:application extends="force:slds">
   <div class="slds"> 
      <div class="slds-page-header"> 
        <div class="slds-grid">  
          <div class="slds-col slds-has-flexi-truncate">  
              <p class="slds-text-heading--label">Expenses</p>
              <div class="slds-grid"> 
                <div class="slds-grid slds-type-focus slds-no-space">
                    <h1 class="slds-text-heading--medium slds-truncate" title="My
                    Expenses">My Expenses</h1>
                </div>
              </div>   
      <c:ExpenseCmt /> 
          </div>    
        </div>    
     </div>
  </div>    
</aura:application>
But i unable to pass the string as a class name in Db.executebatch();
public class DynamicBatchClass {
    public string selectedclass{get;set;}
    public string classname{get;set;}
    public string inputquery{get;set;}
    public DynamicBatchClass(){
       
    }
    public list<selectoption> getclassnameslist ()
    {
        map<string,sobject> instanceMap=new map<string,sobject>();
        list<selectoption> options=new list<selectoption>();
       system.debug('---->>>>-');
         list<ApexClass> ClassNames=new list<ApexClass>();
        options.add(new selectoption('--None--','--None--'));
        ClassNames=[select Id,name,body from ApexClass];
        for(ApexClass ac:ClassNames)
        { 
           if(ac.body.contains('batch')){
           system.debug('-----'+ac.name);
           options.add(new selectoption(ac.Id,ac.name));
           instanceMap.put(ac.name, ac);
           system.debug('--instanceMap--'+instanceMap);
      }
     }
     
   return options;
 }
 
 public void run(){
     system.debug('--selectedclasses--'+selectedclass);
     system.debug('--query-->'+inputquery);
    ApexClass newAp = [select id, name from apexclass where id=:selectedclass];
    string s = newap.Name;
    Database.executeBatch(new s() ,50);
  }
}

Any one help me to pass the classname

VF :- <apex:page controller="DynamicBatchClass" showHeader="false" standardStylesheets="false" sidebar="false" docType="html-5.0" applyBodyTag="False" applyHtmlTag="False">    
   <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" lang="en" >
    <apex:stylesheet value="{!URLFOR($Resource.SLDS24, 'assets/styles/salesforce-lightning-design-system-vf.min.css')}" />
 <apex:form>
     
      <div class="slds" role="banner">
      <div class="slds-grid">
             <div class="slds-form-element">
  <label class="slds-form-element__label" for="text-input-01">Input Label</label>
  <div class="slds-form-element__control">
    <input type="text" id="text-input-01" class="slds-input" placeholder="Placeholder Text" />
  </div>
</div>
              <div class="slds-text-heading--large">Select Batch Class</div>
             <apex:selectList value="{!selectedclasses}" multiselect="false" size="1" label="Select Batch Class">
                 <apex:selectOptions value="{!classnameslist}"></apex:selectOptions>
             </apex:selectList>
       </div>   
    </div>
    <apex:pageblock >
     
         <apex:pageBlockSection >
             <apex:inputTextArea label="Query"></apex:inputTextArea>
        </apex:pageBlockSection>
     </apex:pageblock>
 </apex:form>
  </html>
</apex:page>
trigger Example on Product2 (before insert,before update,after insert,after update) {

        System.debug('Inside Trigger ** -->');

        Product2TriggerHelper helper = new Product2TriggerHelper();
        if(!System.label.SYS_RunAPTS_ProductTrigger.equalsIgnoreCase('NO')){
            if (Trigger.isInsert && Trigger.isAfter) {
                 try{
                    
                    helper.onAfterInsert(Trigger.New);
                 }catch(Exception ex){
                     system.debug('Exception exists while inserting PriceListItem' + ex.getMessage());
                 }
            }
            if (Trigger.isUpdate && Trigger.isAfter) {
                try{

                    helper.onAfterUpdate(Trigger.New);
                 }catch(Exception ex){
                     system.debug('Exception exists while inserting PriceListItem' + ex.getMessage());
                 }
            }
        }
    }

Thanks in advance.
Display popup when logged user 'Contact' is having birthday today, Please help me with this

Thanks 
Hi Team,

Could you please check below link?
https://developer.salesforce.com/page/Best_Practice:_Avoid_SOQL_Queries_Inside_FOR_Loops

In this link they used trigger.new.keyset in before insert event ( in a code where they used best practise). I read somewhere that if we use trigger.newmap.keyset in before insert then it will give null id's.

Could you please clarify my doubt?
Hi,

I just wanted to check if time based wrkflow work for the below requirement

1) if case record is not modified for 90 days then the case status should automatically be set as closed

i have created a time based workflow where case modified date is greater than 90 days and the time dependent workflow actions as a field update to set te status to closed

Let me know your thoughts on it

Thanks in Advance
Hi All,

I am getting below error . pls help me on this 
System.QueryException: List has no rows for assignment to SObject 
Class.mySecondController.getAccount: line 5, column 1
public class mydbController {

  public Account getAccount() {
  

    return [select id, name,

            (select id, firstname, lastname

             from Contacts limit 5)

            from Account where id =

             :System.currentPageReference()

             .getParameters().get('id')];

  }

}

 
Hey there!

I'm a Senior Admin looking for projects I can complete on a remote basis. I'm 6X Certified and working to expand my knowledge in different types of orgs! Core competencies include the following:

-Process Automation
-Configuration/Customizations
-Reporting
-Visual Workflow
-Data Migration
-Solutions Testing

I have reasonable rates and will negotiate based on timing/project. Happy to provide references, resume and other evidence of certification upon request!

Thanks,

Travis
can you explain this.
string st='test';
list<sobject> str=database.query('select id,name from account where name like' +'\''+st+'\'');

can anyone explain clearly , How system understand these characters after like
        +'\''+st+'\''
 
User-added image
<aura:component controller="searchAccountController">
   <ltng:require styles="{! $Resource.SLDS24+ '/assets/styles/salesforce-lightning-design-system.css'}"/>
    <aura:attribute name="searchResult" type="List" description="use for store and display account list return from server"/>
   <aura:attribute name="searchKeyword" description="use for input" type="string" ></aura:attribute>
    <aura:attribute name="Message" type="boolean" default="false" description="use for display no record found message"/>
    <div class="slds-m-around--large">
       <form class="slds-form--inline"> 
         <div class="slds-form-element"> 
            <label class="slds-form-element__label" for="Search">Account Search</label>  
              <div class="slds-form-element__control" >
                <ui:inputtext aura:id="searchId" value="{!v.searchKeyword}" placeholder="Type Account Name" required="true" class="slds-input"></ui:inputtext>
              </div>
            </div> 
             <div class="slds-form-element">
                 <button type="Button" onclick="{!c.Search}" class="slds-button slds-button--brand">Search</button>
                 </div>
        </form>   
        <table class="slds-table slds-table--bordered slds-table--cell-buffer">
            <thead>
                <tr class="slds-text-title--caps">
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> ID</div>
                    </th>
                    <th scope="col">
                         <div class="slds-truncate" title=" Name"> Name</div>
                    </th>   
                     <th scope="col">
                          <div class="slds-truncate" title="Type">Type</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Industry">Industry</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Phone">Phone</div>
                       </th>
                       <th scope="col">
                          <div class="slds-truncate" title="Fax">Fax</div>
                       </th>
                </tr>
            </thead>
            <tbody>
            <aura:if isTrue="{!v.Message}">
               <div class="slds-text-color--error"> No Result Found...</div>
            </aura:if>
                <aura:iteration items="{!v.searchResult}" var="acc"> 
              <tr>
                  <td>
                     <div class="slds-truncate">{!acc.Id}</div>
                  </td>
                   <td>
                     <div class="slds-truncate">{!acc.name}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!acc.Type}</div>
                  </td>
                  <td>
                     <div class="slds-truncate">{!acc.industry}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!acc.Phone}</div>
                  </td>
                    <td>
                     <div class="slds-truncate">{!acc.fax}</div>
                  </td>
              </tr>
                </aura:iteration>    
            </tbody>
        </table>
      </div>     
     
</aura:component>
 
trigger createcontacts on Account (after insert) {
   
     list<contact> con=new list<contact>();
     
    list<id> l1=new list<id>();
   for(account acc:trigger.new)
  {
   l1.add(acc.id);  
 }
   if(l1.size()>0 && l1!=null)
    {
     contact c1=new contact();
     c1.accountid=l1.id;
     c1.firstname=l1.name;
     con.add(c1);
     }
     insert con;
     }
In account page,the contact is created ,I want to show the number of count of contacts records created that is associated with that account.I have tried to write the trigger for that.But some error getting in that trigger.Please rectify to solve that bugs.    

trigger NoofCountContacts on Account (after insert,after update) {
   List <Account> con = new List <Account>();
   for (contact con1:Trigger.new){
      String Id= Apexpages.currentPage().getParameters().get('Account.Id');
   Integer sum =[SELECT COUNT() FROM contact where accid =:Trigger.old.keyset(Id)];
   con.Number_Of_Contacts= sum;
   }
   update con;
   }