• DILEEP NALLA
  • NEWBIE
  • 15 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 5
    Replies
Hi,

I have a requirement of filtering drop down list based on the another drop down list

I have two custom settings countries and states, based on countries filter I have to filter states.
Here is my code:
public with sharing class CountryStatePicker {
    public Apexpages.StandardController stndctrl;
    Public Custom_Info__c CSP {get;set;}
     Public CountryStatePicker(Apexpages.StandardController stndctrl)
    {
        CSP = (Custom_Info__c)stndctrl.getrecord();
        this.stndctrl= stndctrl;
    }
    
    
  // Variables to store country and state selected by user 
    Public string state{get;set;}
    Public string country{get;set;}
    
  // Generates country dropdown from country settings
    public List<SelectOption> getCountriesSelectList()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--Select Countries--'));
    
   // Find all the countries in the custom setting
    Map<String, Foundation_Countries__c> countries = Foundation_Countries__c.getAll();
    
   // Sort them by name
    List<String> countryNames = new List<String>();
    countryNames.addAll(countries.keySet());
    countryNames.sort();
   // Create the Select Options.
    for (string countryName : countryNames ){
        Foundation_countries__c Country = countries.get(countryName);
        options.add(new SelectOption(country.country_code__c, country.Name));
    }
    
    return options;
}
    // To generate the states picklist based on the country selected by user.

    public List<SelectOption> getStatesSelectList() {

        List<SelectOption> options = new List<SelectOption>();

        // Find all the states we have in custom settings.
        Map<String, Foundation_States__c> allstates = Foundation_States__c.getAll();

        // Filter states that belong to the selected country
        Map<String, Foundation_States__c> states = new Map<String, Foundation_States__c>();
        for(Foundation_States__c state : allstates.values()) {
            if (state.country_code__c == this.country) {
                states.put(state.name, state);
            }
        }
        // Sort the states based on their names
        List<String> stateNames = new List<String>();
        stateNames.addAll(states.keySet());
        stateNames.sort();
        // Generate the Select Options based on the final sorted list
        for (String stateName : stateNames) {
            Foundation_States__c state = states.get(stateName);
            options.add(new SelectOption(state.state_code__c, state.state_name__c));
        }
       // If no states are found, just say not required in the dropdown.
        if (options.size() > 0) {
            options.add(0, new SelectOption('', '-- Select One --'));
        } else {
            options.add(new SelectOption('', 'Not Required'));
        }
        return options;
    }
}

-------------

My Vf Page code:
<apex:page standardController="Custom_Info__c" extensions="CountryStatePicker">
   <apex:form >
      <apex:actionFunction name="rerenderStates" rerender="statesSelectList" >
          <apex:param name="firstParam" assignTo="{!country}" value="" />
      </apex:actionFunction>

       <apex:pageBlock>
          <apex:pageBlockSection columns="2" showHeader="true" title="Application Information Section" collapsible="true"> 
                  <apex:selectList size="1" value="{!country}" id="country" onChange="rerenderStates(this.value)" >
                    <apex:selectOptions value="{!countriesSelectList}"/>
                     <apex:actionSupport event="rerenderStates(this.value)"/>
                 </apex:selectList>
            <apex:selectList size="1" value="{!country}" id="statesSelectList" tabindex="1" >
                <apex:selectOptions value="{!statesSelectList}"/>
                 </apex:selectList>
          </apex:pageBlockSection>  
      
      </apex:pageBlock>  
    <apex:inputField id="description" value="{!CSP.Describe_Our_State__c}" required="true" taborderhint="2" />
       <apex:pageBlock >
        <apex:commandButton value="Save" action="{!Save}" tabindex="8" />   
       </apex:pageBlock>     
    </apex:form>
    
</apex:page>



 
Hi,

Currently we have configured the whitelabel  in our account and now we need to configure another.
Is it possible to have the mutiple in a single org? If yes can you please help me or please provide tips

Thanks in advance!
 
User-added image


Hi
I have a below requirement,
I have created an object for calculating mileage vs cost for bike
I have the below fields in my object:
 Object Name:
API NameMileage_vs_Cost__c
Bill AmountBill_Amount__c
Current ReadingCurrent_Reading__c
DateDate__c
Past ReadingPast_Reading__c
PetrolUserName__c
Petrol User is a master object for( Mileage_Vs_ Cost__c) object
Example : For the first time when I save my record, current reading is zero fueled on 3/21/2016,
I will be travelling whole month and next time when I am ready to fuel the petrol , I will be entering some 1000 kms as current reading and when I do this process I want the past reading(i.e; previous month's current reading which is 0(zero) when I filled fuel on 3/21/2016) to  get populated in Past_reading__c filed of my record….
So that I can calculate mileage = (Current reading - past reading) and based on this further developments I can do on the page; can any one help me in this requirement I feel grateful and I am trying it using List and triggers and am failing…
I have requirement that I need to make sure previous month record should not be entered in current month
I need to validate Previous month and current month
How to implement this code using triggers ?
Apex code required..Please help
There is one record in my application having Current_Month__c= False(data type Formula) && Current_Month_Record__c=True ,(data type Checkbox) . If this is the case by using Batch apex concepts I want update Current_Month_Record__c as false if Current_Month__c= False.For this I have written below code which is not executing.
In code I am not getting any error but while executing No changes are being updated
User-added image
Code I have written for this
 
Global class RoomatebatchClass implements Database.Batchable<Sobject>
{
              
    Global Database.QueryLocator start(Database.BatchableContext BC) // this will divide batch into batches of equal size
    {
       // String strquery='Select id,Name,Month_of_Expenditure__c,Current_Month_Record__c from MyRoomExpenditure__c where Current_Month__c= :False and Current_Month_Record__c= :True';
Return Database.getQueryLocator([Select id,Name,Month_of_Expenditure__c,Current_Month_Record__c from MyRoomExpenditure__c where Current_Month__c=: False and Current_Month_Record__c=: True]);---à(//Query to pull records meeting my criteria where Current_Month__c=: False and Current_Month_Record__c=: True] )
                  
    }
   
    // BatchableContext is used to communicate between the methods about the status of execution of Batch Apex class
   Global Void execute ( Database.BatchableContext BC, List <MyRoomExpenditure__c>  lstRoomExp) 
    {
      
        List <MyRoomExpenditure__c> lstMyroomrecords = new List<MyRoomExpenditure__c>();
                     
            for (Sobject objrec :lstRoomExp )
            {
                MyRoomExpenditure__c myroomexp = (MyRoomExpenditure__c) objrec ;
                if(myroomexp.Current_Month_Record__c==True)
                                {
                                                myroomexp.Current_Month_Record__c= false;
//myroomexp.Current_Month_Record__c=null;-à I even tried this
 
                                                }
                lstMyroomrecords.add(myroomexp);---- I tried commenting this and execute but No luck
            }
   update lstMyroomrecords;       
        
    }
   
    Global void finish(Database.BatchableContext BC)
    {
                system.debug('Batch Job Id is...: ' + BC.getJobID() );
                               
                                // Get the Batch Job Details..
                               
                                AsyncApexJob jobDetails = [ select id, status, numberoferrors, totaljobitems, jobitemsprocessed, createdby.email from AsyncApexJob where id =: BC.getJobID() ];
                               
                                // Send the Job Details to User by Email..
                               
                                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                               
                                string[] toAddress = new string[] {jobDetails.CreatedBy.Email};
                               
                                // Email Subject..
                                string subject = 'AccountUpdateBatch Execution Status : ' + jobDetails.Status;
                               
                                // Email Content..
                                string content = 'Batch Job AccountUpdateBatch Id ...: '+ jobDetails.ID + '<br/><br/>' +
                                ' Batch Job Status ...: ' + jobDetails.Status + '<br/><br/>' + ' Total Job Items ....: ' + jobDetails.totaljobitems + '<br/><br/>'+
                                'Number of Errors ...: ' + jobDetails.numberoferrors + '<br/><br/>' + ' Job Items Processed ....: ' + jobDetails.jobitemsprocessed + '<br/><br/>' ;
                               
                                email.SetToAddresses(toAddress);
                                email.SetSubject(subject);
                                email.SetHTMLBody(content);
                               
                                Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});
                               
               
    }
}


 
User-added image


Hi
I have a below requirement,
I have created an object for calculating mileage vs cost for bike
I have the below fields in my object:
 Object Name:
API NameMileage_vs_Cost__c
Bill AmountBill_Amount__c
Current ReadingCurrent_Reading__c
DateDate__c
Past ReadingPast_Reading__c
PetrolUserName__c
Petrol User is a master object for( Mileage_Vs_ Cost__c) object
Example : For the first time when I save my record, current reading is zero fueled on 3/21/2016,
I will be travelling whole month and next time when I am ready to fuel the petrol , I will be entering some 1000 kms as current reading and when I do this process I want the past reading(i.e; previous month's current reading which is 0(zero) when I filled fuel on 3/21/2016) to  get populated in Past_reading__c filed of my record….
So that I can calculate mileage = (Current reading - past reading) and based on this further developments I can do on the page; can any one help me in this requirement I feel grateful and I am trying it using List and triggers and am failing…
There is one record in my application having Current_Month__c= False(data type Formula) && Current_Month_Record__c=True ,(data type Checkbox) . If this is the case by using Batch apex concepts I want update Current_Month_Record__c as false if Current_Month__c= False.For this I have written below code which is not executing.
In code I am not getting any error but while executing No changes are being updated
User-added image
Code I have written for this
 
Global class RoomatebatchClass implements Database.Batchable<Sobject>
{
              
    Global Database.QueryLocator start(Database.BatchableContext BC) // this will divide batch into batches of equal size
    {
       // String strquery='Select id,Name,Month_of_Expenditure__c,Current_Month_Record__c from MyRoomExpenditure__c where Current_Month__c= :False and Current_Month_Record__c= :True';
Return Database.getQueryLocator([Select id,Name,Month_of_Expenditure__c,Current_Month_Record__c from MyRoomExpenditure__c where Current_Month__c=: False and Current_Month_Record__c=: True]);---à(//Query to pull records meeting my criteria where Current_Month__c=: False and Current_Month_Record__c=: True] )
                  
    }
   
    // BatchableContext is used to communicate between the methods about the status of execution of Batch Apex class
   Global Void execute ( Database.BatchableContext BC, List <MyRoomExpenditure__c>  lstRoomExp) 
    {
      
        List <MyRoomExpenditure__c> lstMyroomrecords = new List<MyRoomExpenditure__c>();
                     
            for (Sobject objrec :lstRoomExp )
            {
                MyRoomExpenditure__c myroomexp = (MyRoomExpenditure__c) objrec ;
                if(myroomexp.Current_Month_Record__c==True)
                                {
                                                myroomexp.Current_Month_Record__c= false;
//myroomexp.Current_Month_Record__c=null;-à I even tried this
 
                                                }
                lstMyroomrecords.add(myroomexp);---- I tried commenting this and execute but No luck
            }
   update lstMyroomrecords;       
        
    }
   
    Global void finish(Database.BatchableContext BC)
    {
                system.debug('Batch Job Id is...: ' + BC.getJobID() );
                               
                                // Get the Batch Job Details..
                               
                                AsyncApexJob jobDetails = [ select id, status, numberoferrors, totaljobitems, jobitemsprocessed, createdby.email from AsyncApexJob where id =: BC.getJobID() ];
                               
                                // Send the Job Details to User by Email..
                               
                                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                               
                                string[] toAddress = new string[] {jobDetails.CreatedBy.Email};
                               
                                // Email Subject..
                                string subject = 'AccountUpdateBatch Execution Status : ' + jobDetails.Status;
                               
                                // Email Content..
                                string content = 'Batch Job AccountUpdateBatch Id ...: '+ jobDetails.ID + '<br/><br/>' +
                                ' Batch Job Status ...: ' + jobDetails.Status + '<br/><br/>' + ' Total Job Items ....: ' + jobDetails.totaljobitems + '<br/><br/>'+
                                'Number of Errors ...: ' + jobDetails.numberoferrors + '<br/><br/>' + ' Job Items Processed ....: ' + jobDetails.jobitemsprocessed + '<br/><br/>' ;
                               
                                email.SetToAddresses(toAddress);
                                email.SetSubject(subject);
                                email.SetHTMLBody(content);
                               
                                Messaging.SendEmail(new Messaging.SingleEmailMessage[] {email});
                               
               
    }
}