• mohdAnas
  • NEWBIE
  • 78 Points
  • Member since 2017
  • Developer
  • Techmatrix Consulting


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
global class BatchJobStatus implements Database.Batchable<sObject>,Database.AllowsCallouts

{
 public String query;
 global Database.querylocator start(Database.BatchableContext BC){
        query = 'Select id, AccountId, Account_Company_Id__c, JobDiva_ID__c, StageName from Opportunity where (JobDiva_ID__c!=null AND StageName ="Lost")';
        return Database.getQueryLocator(query);
    }
 global void start(){
        Database.executeBatch(new BatchJobStatus(),100);
    } 

global void execute(Database.BatchableContext bc, List<Opportunity> oppList){
       for (Opportunity opp : oppList) {
        if (opp.StageName=='Lost'){
opp.StageName = 'Closed';
        }
           try{
                update oppList;
            }
   catch(Exception e) {
            System.debug(e);
        }
         
    }    
}
global void finish(Database.BatchableContext bc){
     
    }    
}
I am having a piece of code which fetches countryname along with its code from custom setting
and populates the country name into the visual force page.

In custom setting, type=LIST , anme is Countries__c and it has a field called CountryCode__c.

if the user selects Australia from vf page and click SAVE button then 'CA' is stored in the backend and so on.
The values in custom settings are not very huge.

Now i need to have another picklsit in vf page , which will display the state name based on the country selected.

I want to store the states names also in custom settings(state names are not many just a few).

Here is what I have achieved so far.
 
public List<SelectOption> CountryCodeList=new List<SelectOption>();

public String selectedCountryCode {get; set;}

 public  List<SelectOption> getCountryCodes() 
   {
        if(countryCodeList.isEmpty())
        {
           countryCodeList=new List<SelectOption>();
           List<Countries__c> allCountries = new List<Countries__c>();

           allCountries = [SELECT  Name,CountryCode__c
                                  FROM    Countries__c];

             
          allCountries.sort();
          
List<Countries__c> cList=new List<Countries__c>([select CountryCode__c 
                                                        from Countries__c 
                                                        where CountryCode__c=:selectedCountryCode]);
          
          if (cList.size() > 0)
          {
          
            for(Countries__c country : allCountries )
            {
              
                countryCodeList.add( new SelectOption( country.CountryCode__c, country.Name ) );
            }
          }
          else
          {
             countryCodeList.add(new SelectOption('--Select--', '--Select--'));

          }
       } 
     
        return countryCodeList;
   }
   
   

<apex:selectOption itemValue=" " itemLabel="--Select--"></apex:selectOption>
<apex:selectOptions value="{!countryCodes}"></apex:selectOptions>
</apex:selectList>

Please let me know how to capture value of first picklsit and based on that get the states for that country.
also how to design the custom setting so as to include the states and how to use changes in vf page.

I request the forum members to help me out urgently.

Thanks
krishna
 
Hi ,

I need help on below requirement as follows,

I am having a campiagn member object record

I want to have a custom button on campiagn member called "Convert opportunity"

on click of it should take me to opportunity record  creation page with the account tagged in campaign member to be automatically tagged on account field on opportunity

If i go back to campiagn member and change the account and click on the convert opportunity again it should reflect the new account tagged to that respective campiagn member

Help me how to acheive this]

Thanks in Advance

 
global class BatchJobStatus implements Database.Batchable<sObject>,Database.AllowsCallouts

{
 public String query;
 global Database.querylocator start(Database.BatchableContext BC){
        query = 'Select id, AccountId, Account_Company_Id__c, JobDiva_ID__c, StageName from Opportunity where (JobDiva_ID__c!=null AND StageName ="Lost")';
        return Database.getQueryLocator(query);
    }
 global void start(){
        Database.executeBatch(new BatchJobStatus(),100);
    } 

global void execute(Database.BatchableContext bc, List<Opportunity> oppList){
       for (Opportunity opp : oppList) {
        if (opp.StageName=='Lost'){
opp.StageName = 'Closed';
        }
           try{
                update oppList;
            }
   catch(Exception e) {
            System.debug(e);
        }
         
    }    
}
global void finish(Database.BatchableContext bc){
     
    }    
}
How do I use "IF/ELSE" logic (or something better) to avoid displaying a pageblock completely if the related list is empty.  In the code below, a pageblock gets displayed that shows a certain list that is related list.  It is possible that the related list is empty.  The problem is that even if the relatedList has no data, an empty block "Higher Probability" gets displayed.  How do I avoid displaying the pageBlock completely if the relatedList is empty?

Thanks
<apex:pageBlock title="Higher Probability">
        <apex:pageBlockTable value="{! highLikelihoodDeals }" var="ds">
            <apex:column value="{! ds.Issuer__c }"/>
            <apex:column headerValue="Bids Due" value="{! ds.Circle_Due_Date__c }"/>
            <apex:column headerValue="Maturities">            
                    <apex:pageBlockTable value="{!ds.Tranches__r}" var="val">
                        <apex:column headerValue="Tenor" value="{! val.name }"/>
                    </apex:pageBlockTable>
            </apex:column>
            <apex:column headerValue="Comments" value="{! ds.Deal_Description__c }"/>
        </apex:pageBlockTable>
    </apex:pageBlock>

 
I am getting 56% coverage, I am also getting an Attempt to de-reference a null object with this line of code 'CustomerInfoSheet ac = new CustomerInfoSheet();'

@IsTest
public class CustomerInfoSheetTest {

 static testMethod void testCustomerInfoSheet() {

     Account a = new Account();
      a.Name='TestAccount';
      a.Industry='AG';
     a.Region__c = 'Delta';
      insert a;
     
     a =[SELECT Id, Name, Industry, Region__c FROM Account testAccount WHERE Name=:a.Name];
     system.assert(true, a.Id);
     if (a != null) {
            
            }
     
       
     PageReference pageRef = Page.CustomerInfoSheet;
   pageRef.getParameters().put('id',a.id);
     test.setCurrentPage(pageRef);
     
     CustomerInfoSheet ac = new CustomerInfoSheet();
     
   
    test.startTest();  
     ac.PrintOut=a.Id;
        pageRef = ac.CustomerInfoSheet();
     System.assertEquals(pageRef.getUrl(), '/'+a.Id);
    test.stopTest();
     
 }    
}
I am creating a VF page to mass issue books in a library management system. I have a custom junction object (Book_Issue__c) which is a child of Book__c object and Contact object.
 
I am using the following code for the VF Page
<apex:page Controller="MultipleBookIssue" >
    
    
    <apex:form >
        <apex:pageBlock title="Mass Issue Books">
            
            <apex:pageBlockTable Value="{!listBookIssue}" var="issue" id="table" >
                <apex:column headerValue="Select">
                    
                    <apex:inputCheckbox value="{!issue.selected}"/>
                    
                </apex:column>        
                <apex:column headerValue="Book" >
                    
                    <apex:inputField value="{!issue.bi.Book__c}"/>
                </apex:column>
                <apex:column headerValue="Issued To" >
                    <apex:inputField value="{!issue.bi.Issued_To__c}"/>
                </apex:column>
                
                <apex:column headerValue="Issue Date" >
                    <apex:inputField value="{!issue.bi.Book_Issue_Date__c}"/>
                </apex:column>        
                
            </apex:pageBlockTable>
            <apex:pageBlockButtons location="Bottom" >
                <apex:commandButton value="Add Book Issue Row" action="{!addBookIssueRow}" immediate="true"/>
           
                <apex:commandButton value="Delete Book Issue Row" action="{!deleteBookIssueRow}" rendered="true" />
          
                <apex:commandButton action="{!saveBookIssue}" value="Save Book Issue"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
 
</apex:page>

User-added imageUser-added image
 
public class MultipleBookIssue {
    
    public list<wBookIssue> listBookIssue{get;set;}
    
    public void deleteBookIssueRow() {
        
        System.debug('before: ' + listBookIssue);
        
        Integer j=0;
        while(j<listBookIssue.size())
        {
            if(listBookIssue.get(j).selected==true){
                listBookIssue.remove(j);
                j--;
            }
            j++;
        }
/*
        List<Integer> deleteList = new List<Integer>();
        Integer i =0;
        for(wBookIssue wbi : listBookIssue) {
            if(wbi.selected == true) {
                deleteList.add(i);
                listBookIssue.remove(i);
            }
            i++;
        }
        */
        
        System.debug('after: ' + listBookIssue);
        
    }
    
    
    
    public MultipleBookIssue(){
        listBookIssue= new list<wBookIssue>();
        listBookIssue.add(new wBookIssue());
    }
    
    public void addBookIssueRow(){
        listBookIssue.add(new wBookIssue());
    }
    
    public PageReference saveBookIssue()
    {
        List<Book_Issue__c> biList = new List<Book_Issue__c>();
        for(wBookIssue wbi : listBookIssue) {
            biList.add(wbi.bi);
        }
        
        insert biList;
        
        return Page.AllBooksIssued;
    }
    
    public class wBookIssue {
        public Book_Issue__c bi {get; set;}
        public boolean selected {get; set;}
        
        public wBookIssue() {
            bi = new Book_Issue__c();
            selected = false;
        }
    }
}
 
But I am not able to delete the row.. I am attaching the screenshot of the vf page.
 
trigger Intervieee on Interviewer__c (after Update)

{

Set<Decimal> setPhoneNumber = new Set<Decimal>();
for(Interviewer__c i:trigger.new)
{
   if(i.Mobile_no__c != null)
{
// As per your current logic you are checking old value not new
   Interviewer__c invSet=Trigger.oldMap.get(i.Id);
   setPhoneNumber.add(invSet.Mobile_no__c);

}

    }
    if( setPhoneNumber.size() > 0 )
    {
    List<Candidates__c> canList = [select Name,Phone_Number__c,Qualification__c,Rating__c,Review_comments__c,Result__c,Mobile_no__c
              from Candidates__c where Mobile_no__c = :setPhoneNumber ];

                                         

        Map<Decimal ,Candidates__c> mapPhoneWiseCand = new Map<Decimal ,Candidates__c>();

        for( Candidates__c cand : canList )

        {

            mapPhoneWiseCand.put( cand.Mobile_no__c , cand );

        }

         

        list<Candidates__c> updatedcand=new list<Candidates__c>();

        for(Interviewer__c i:trigger.new)

        {

            if(i.Mobile_no__c != null)

            {

                Interviewer__c invSet=Trigger.oldMap.get(i.Id);

                if( mapPhoneWiseCand.containsKey( invSet.Mobile_no__c ) )

                {

                    Candidates__c canList1 = mapPhoneWiseCand.get(invSet.Mobile_no__c);

                     

                    canList1.Name=i.CName__c;

                    canlist1.Phone_Number__c=i.Phone_Number__c;

                    canlist1.Qualification__c=i.Candidate_s_qualification__c;

                    canlist1.Rating__c=i.Rating__c;
                    canlist1.Review_comments__c=i.Review_Comments__c;

                    canlist1.Result__c=i.Result__c;

                    canlist1.Mobile_no__c=i.Mobile_no__c;

                     

                    updatedcand.add(canList1);
                }

            }

        }

        if(updatedcand.size() > 0 )

        {

            try{

                system.debug('Before update');

                update updatedcand;

                system.debug('After update');

           }

            catch(Exception e){}

             

        }  

         

    }  

}

Please help.
Please help in writting test class for below controller 
Controller : 
public with sharing class accountLst {

      public static Map<Id, String> recordtypemap {get;set;}
    
   @AuraEnabled        
    public static List<String> fetchRecordTypeValues(){
        List<Schema.RecordTypeInfo> recordtypes = Account.SObjectType.getDescribe().getRecordTypeInfos();    
        recordtypemap = new Map<Id, String>();
        for(RecordTypeInfo rt : recordtypes){
            if(rt.getName() != 'Master')
            recordtypemap.put(rt.getRecordTypeId(), rt.getName());
        }        
        return recordtypemap.values();
    }
    
    @AuraEnabled
    public static Id getRecTypeId(String recordTypeLabel){
        Id recid = Schema.SObjectType.Account.getRecordTypeInfosByName().get(recordTypeLabel).getRecordTypeId();        
        return recid;
    }    
    
    @AuraEnabled
    public static List<account> findByName(String cName){
        
        String nm='%'+cName+'%';
        return [SELECT id, Name, Phone, Post_Code__c, Categories_del__c FROM Account where Name LIKE :nm LIMIT 20];
          
    }
}
Hi All,

I am trying to call "Python" Script from salesforce. Can you please guide me for this.  
How to call "Python" Script from Salesforce
I am having a piece of code which fetches countryname along with its code from custom setting
and populates the country name into the visual force page.

In custom setting, type=LIST , anme is Countries__c and it has a field called CountryCode__c.

if the user selects Australia from vf page and click SAVE button then 'CA' is stored in the backend and so on.
The values in custom settings are not very huge.

Now i need to have another picklsit in vf page , which will display the state name based on the country selected.

I want to store the states names also in custom settings(state names are not many just a few).

Here is what I have achieved so far.
 
public List<SelectOption> CountryCodeList=new List<SelectOption>();

public String selectedCountryCode {get; set;}

 public  List<SelectOption> getCountryCodes() 
   {
        if(countryCodeList.isEmpty())
        {
           countryCodeList=new List<SelectOption>();
           List<Countries__c> allCountries = new List<Countries__c>();

           allCountries = [SELECT  Name,CountryCode__c
                                  FROM    Countries__c];

             
          allCountries.sort();
          
List<Countries__c> cList=new List<Countries__c>([select CountryCode__c 
                                                        from Countries__c 
                                                        where CountryCode__c=:selectedCountryCode]);
          
          if (cList.size() > 0)
          {
          
            for(Countries__c country : allCountries )
            {
              
                countryCodeList.add( new SelectOption( country.CountryCode__c, country.Name ) );
            }
          }
          else
          {
             countryCodeList.add(new SelectOption('--Select--', '--Select--'));

          }
       } 
     
        return countryCodeList;
   }
   
   

<apex:selectOption itemValue=" " itemLabel="--Select--"></apex:selectOption>
<apex:selectOptions value="{!countryCodes}"></apex:selectOptions>
</apex:selectList>

Please let me know how to capture value of first picklsit and based on that get the states for that country.
also how to design the custom setting so as to include the states and how to use changes in vf page.

I request the forum members to help me out urgently.

Thanks
krishna
 
Hi ,

I need help on below requirement as follows,

I am having a campiagn member object record

I want to have a custom button on campiagn member called "Convert opportunity"

on click of it should take me to opportunity record  creation page with the account tagged in campaign member to be automatically tagged on account field on opportunity

If i go back to campiagn member and change the account and click on the convert opportunity again it should reflect the new account tagged to that respective campiagn member

Help me how to acheive this]

Thanks in Advance

 

Access a Child record from Parent account on visualforce using lookup field. For Example
Parent Account : ABC, child Account : 123 ,1A2 ,2B1
My VF page :
<apex:page standardController="Account">
   <apex:pageBlock>
                   <apex:pageBlockSection collapsible="true" title="Filters" columns="1" >
                                     <apex:inputField value="{!Account.name}" />  
<!-- Display only Parent Account Name but i want display lookup icon with all child record related to parent account .-->
                   </apex:pageBlockSection>
   </apex:pageBlock>
</apex:page>