• Pratibh
  • NEWBIE
  • 50 Points
  • Member since 2009

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies

I  have two selectList,list1 and list2. the option of list2 is add according the selected item in list1 automaticly in javascript.

the code is:

 

<script>
 var hotel=new Array();
 var brand=new Array();
 var type=new Array();
 <apex:outputText escape="false" value="{!MyHotel}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyBrand}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyType}"></apex:outputText>
function list2(list2id,n)
{
 var list=document.getElementById(list2id);


 for(var i=list.length-1;i>=0;i--)list.remove(i);
 for(var i=0;i<hotel.length;i++)
 list.add(new Option(hotel[i],hotel[i]));
 }
</script>
<apex:outputPanel id="result">
<apex:form >
<b>Report By: </b>
<apex:selectList id="list1" multiselect="false"  size="1" value="{!reporttype}"  onchange="list2('{!$Component.list2}');">
<apex:selectOption itemValue="1" itemLabel="Hotel"></apex:selectOption>
<apex:selectOption itemValue="2" itemLabel="Hotel Brand"></apex:selectOption>
<apex:selectOption itemValue="3" itemLabel="Hotel Type"></apex:selectOption>
</apex:selectList>
<b>Please select :</b>
<apex:selectList id="list2" multiselect="false" size="1" value="{!reportby}">
</apex:selectList>
<apex:commandButton value="Go!" action="{!doSearch}" status="status"  reRender="result"/>

<apex:form>

</apex:outputPanel >

 

the problem is I can't get the value of reportby in my apex, where is the problem?

Hi all,

 

My "Lead" has a related list called "Interest". It's a custom object.

 

Interest has a custom field called "isActive". It's a checkbox.

 

What I would like to do are

 -- if isActive is true, that Interest item is shown on the related list.

 -- if isActive is false, that Interest item is not shown on the related list.

 

I know that I can customize what field I show on Lead layout page.

I can choose fields, ex Name,Code,isActive and so on.

 

But I can't find the filtering setting.

 

Is there that setting?

 

If yes, where?

If no, how can I make filtered related list?

 

By VisualForce page?

If so, how can I set on Lead layout page?

 

Thanks,

astraea

Hi,

 

I am new to visualforce.What i am trying to do is:

 

Create a custom search kind of functionality and return results back to VF page based on the values selected.

 

For this :

 

1) I created a new Visualforce page, in which i take two standard Fields of Account ( Type and Rating).

2) I have a button on VF page "Search", when clicked takes values entered in Type and Rating and then returns results.

3) I have taken Standard Controller of "Account" and Extensions for this purpose

 

But, i am unable to see the results, what it shows is "sforce", under results section.

To my surprise, there are no errors also.

 

My VF code:

<apex:page standardController="Account" extensions="customSearch">
    <apex:form>
        <apex:pageBlock title="Custom Search" mode="Edit">
            <apex:pageblockSection title="Select Fields" columns="1" >
                <apex:inputField value="{!Account.Type}"/>
                <apex:inputField value="{!Account.Rating}"/><br/>                                                               
            </apex:pageblockSection>   
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Search" action="{!doSearch}"/>                 
            </apex:pageBlockButtons>                                                         
        </apex:pageBlock>
        
        <apex:pageBlock title="Search Results">
            <apex:pageBlockTable value="{!results}" var="Accts">
                <apex:column headerValue="Account Name">
                    <apex:outputText value="{!Accts.Name}">
                    </apex:outputText>
                 </apex:column>
                 <apex:column headerValue="Account Type">
                    <apex:outputText value="{!Accts.Type}">
                    </apex:outputText>
                 </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    
</apex:page>

 

 

My Apex class for Controller Extension:

 

public class customSearch {

    public customSearch(ApexPages.StandardController controller) {

    }
   String Account_Type;
   public String getAccount_Type(){
       return Account_Type;
   }
   public void setAccount_Type(string Account_Type){
       this.Account_Type=Account_Type;
      }
    
    public List<Account> results=new List<Account>();
    
    public PageReference doSearch(){
        results=[Select Name, Type from Account Where Type=:Account_Type];
        return null;
        }
        
     public List<Account> getResults(){
         return results;
        }
}

 

Can anybody help me with this. 

 

Thanks in advance!

 

Sales4ce

Hi, 

 

I have a VF page that displays details for custom object. 

 

This VF page is accessed via a CommandButton, which calls a method in the Controller --

    PageReference SRPage = new PageReference('/'+customObject.id);

 

The resulting VF page is displayed in the existing window without any sidebar or header.  I would like it to display the SF sidebar and header.  How can I achieve this?

 

Thanks.

  • March 08, 2010
  • Like
  • 0

I  have two selectList,list1 and list2. the option of list2 is add according the selected item in list1 automaticly in javascript.

the code is:

 

<script>
 var hotel=new Array();
 var brand=new Array();
 var type=new Array();
 <apex:outputText escape="false" value="{!MyHotel}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyBrand}"></apex:outputText>
 <apex:outputText escape="false" value="{!MyType}"></apex:outputText>
function list2(list2id,n)
{
 var list=document.getElementById(list2id);


 for(var i=list.length-1;i>=0;i--)list.remove(i);
 for(var i=0;i<hotel.length;i++)
 list.add(new Option(hotel[i],hotel[i]));
 }
</script>
<apex:outputPanel id="result">
<apex:form >
<b>Report By: </b>
<apex:selectList id="list1" multiselect="false"  size="1" value="{!reporttype}"  onchange="list2('{!$Component.list2}');">
<apex:selectOption itemValue="1" itemLabel="Hotel"></apex:selectOption>
<apex:selectOption itemValue="2" itemLabel="Hotel Brand"></apex:selectOption>
<apex:selectOption itemValue="3" itemLabel="Hotel Type"></apex:selectOption>
</apex:selectList>
<b>Please select :</b>
<apex:selectList id="list2" multiselect="false" size="1" value="{!reportby}">
</apex:selectList>
<apex:commandButton value="Go!" action="{!doSearch}" status="status"  reRender="result"/>

<apex:form>

</apex:outputPanel >

 

the problem is I can't get the value of reportby in my apex, where is the problem?

I am getting my test coverage up to snuff for deployment but I have a few page references that are connected to a commandbutton.  I am running a test for this that simply checks to make sure querySelect is not null.  However I am getting an assertion failed:

 

System.Exception: Assertion Failed: Same value: null

 

Now it is clearly not null because I am setting the variable querySelect but I am thinking querySelect is not staying set because of state of a page reference.  I really don't know though and it would be great if someone could give me a little insight as to why this is not working.

 

CONTROLLER CLASS (Some of the class has been omitted)

public class searchController
{
    private List<User> users = new List<User>();
    private List<Business_Unit__c> units = new List<Business_Unit__c>();
    private List<Account> accountResults = new List<Account>();
    private List<Contact> contactResults = new List<Contact>();
    private List<Consultant__c> consultantResults = new List<Consultant__c>();
    private List<Job_Order__c> jobOrderResults = new List<Job_Order__c>();
    private List<Submit__c> submitResults = new List<Submit__c>();
    //private List<Location__c> state = new List<Location__c>();
    //private string[] unit = new string[]{};
    private List<String> unit = new List<String>{};
    public string user = null;
    public string searchType = null;
    public integer unitCount = 0;
    private string queryUnit = null;
    private string queryUser = null;
    public string querySearch = null;
    public string querySelect = null;
   
    //Account Search Variables
    private string accountName = null;
    private string accountId = null;
    private string city = null;
    private string state = null;
   
    //Contact Search Variables
    private string contactName = null;
    private string contactId = null;
    private string contactEmail = null;
   
    //Consultant Search Variables
    private string consultantName = null;
    private string consultantId = null;
    private string consultantHomeEmail = null;
    private string consultantWorkEmail = null;
    private string consultantResume = null;
   
    //Job Order Search Variables
    private string jobOrderId = null;
    private string jobOrderPositionTitle = null;
    private string jobOrderDescription = null;
    private string jobOrderStatus = null;
   
    //Submit Search Variables
    private string submitId = null;
    private string submitStatus = null;
   
    //AJAX variables
    public boolean criteriaVal = false;
    public boolean accountVal = false;
    public boolean contactVal = false;
    public boolean consultantVal = false;
    public boolean jobOrderVal = false;
    public boolean submitVal = false;
    public boolean interviewVal = false;
    public boolean resultsVal = false;
    public boolean resultsTableVal = false;
   
    //Flags
    public boolean unitFlag = false;
    public boolean unitAllFlag = false;
    public boolean userFlag = false;
    public boolean userAllFlag = false;
    public boolean searchFlag = false;
    public boolean unitDisabledFlag = false;
   
    //Error variables
    public boolean noUnitUser = false;
    public boolean noResults = false;
    public boolean disabledUnit = false;

 

    // Account Search
    public PageReference searchAccount()
    {    
        resultsVal = true;
        unitCount = unit.size();
        querySearch = '';
        
        resetUserUnitAllFlag();
        checkUserUnit();
        
        if (userFlag == false && unitFlag == false)
        {
            setBusinessUnit();
            setUser();
            
            querySelect = 'SELECT Id, Account_ID__c, Name, Phone, Industry, Website FROM Account ';
            
            // Search Criteria entered
            if (searchFlag == true)
            {
                // Business Units chosen and All Owners
                if (unitAllFlag == true && userAllFlag == false)
                {
                    querySelect = querySelect + 'WHERE ' + querySearch + 'AND ' + queryUnit + 'ORDER BY Account_ID__c DESC';    
                }
                
                // All Business Units and Owner chosen
                if (unitAllFlag == false && userAllFlag == true)
                {
                    querySelect = querySelect + 'WHERE ' + querySearch + 'AND ' + queryUser + 'ORDER BY Account_ID__c DESC';
                }
                
                // All Business Units and Owners
                if (unitAllFlag == false && userAllFlag == false)
                {
                    querySelect = querySelect + 'WHERE ' + querySearch + 'ORDER BY Account_ID__c DESC';
                }
                
                // Business Units chosen and Owner chosen
                if (unitAllFlag == true && userAllFlag == true)
                {
                    querySelect = querySelect + 'WHERE ' + querySearch + 'AND ' + queryUnit + 'AND ' + queryUser + 'ORDER BY Account_ID__c DESC';
                }
            }
            // No Search Criteria Entered
            else
            {
                // Business Units chosen and All Owners
                if (unitAllFlag == true && userAllFlag == false)
                {
                    querySelect = querySelect + 'WHERE ' + queryUnit + 'ORDER BY Account_ID__c DESC';
                }
                
                // All Business Units and Owner chosen
                if (unitAllFlag == false && userAllFlag == true)
                {
                    querySelect = querySelect + 'WHERE ' + queryUser + 'ORDER BY Account_ID__c DESC';
                }
                
                // All Business Units and Owners
                if (unitAllFlag == false && userAllFlag == false)
                {
                    querySelect = querySelect + 'ORDER BY Account_ID__c DESC';
                }
                
                // Business Units chosen and Owner chosen
                if (unitAllFlag == true && userAllFlag == true)
                {
                    querySelect = querySelect + 'WHERE ' + queryUnit + 'AND ' + queryUser + 'ORDER BY Account_ID__c DESC';
                }    
            }

            accountResults = Database.query(querySelect);
                                
            if (accountResults.size() > 0)
            {
                noResults = false;
            }
            else
            {
                noResults = true;
            }
        }
        
        searchFlag = false;
        return null;
    }

 

    private void checkUserUnit()
    {
        if (user != null)
        {
            userFlag = false;
        }
        else
        {
            userFlag = true;
        }
        
        if (unitCount > 0)
        {
            unitFlag = false;
        }
        else
        {
            unitFlag = true;
        }
    }

}

 

TEST CLASS

@isTest
private class searchTest {
   
    static testMethod void searchTest()
    {
        PageReference pageRef = Page.AdvancedSearch;
       
        Test.setCurrentPageReference(pageRef);
       
        searchController mySearchCon = new searchController();
       
        List<SelectOption> l;
        string s;
        string t = 'true';
        string a = 'test';
        Boolean b;
        PageReference p;           

       
        mySearchCon.user = 'a';
        mySearchCon.unitCount = 1;
        mySearchCon.searchAccount();
        System.assertNotEquals(mySearchCon.querySelect, null);
       
    }
   
}

There are a few required fields in both standard objects and custom objects that I would like to pre-populate when they are created so that the user doesn't feel compelled to fill them in (since they are required).  What I'm talking about is having the data in the field box before the user clicks "save".  I know I can do this after the user clicks "save" (and that is what I'm already doing), but I want the fields filled as soon as the user sees the blank form.

 

Alternatively, is there a way I can make an exception to hide required fields that a trigger will populate before insert?

Hi all'

 

I got a exception as below. Any suggestions? Thanks in advance:

 

"Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger RentMergeTrigger caused an unexpected exception, contact your administrator: RentMergeTrigger: execution of BeforeUpdate caused by: System.Exception: Too many script statements: 10201: Class.RentMerge.RentCalculate: line 70, column 8"

 

Code:

 

 public void RentCalculate(Account a){

      Integer i = 1;

  Decimal DCR = 0;
  Decimal GrossMonthlyRent = 0;
  Decimal H42=0;
  Decimal K38=0;
  Decimal GrossMonthlyExpense=0;
  Decimal TotalExpenses=0;
  Decimal BridgeCapitalRoundup=0;
  Decimal BridgeC=0;
  Decimal PMT1st=0;
  Decimal PMT2nd=0;
  Decimal JV_GIC_Consultant_Fee=0;
  do
  {
       GrossMonthlyRent=i;
     if (a.CMA_Property_Value__c > 250000){JV_GIC_Consultant_Fee=8500;}
     else{JV_GIC_Consultant_Fee=7500;}
     
     if (a.Condo_Fees__c == 0){
    GrossMonthlyExpense=GrossMonthlyRent*0.15;
   }else{
    GrossMonthlyExpense=a.Condo_Fees__c;
   }
     
       H42=(GrossMonthlyRent*(1-0.05))-GrossMonthlyExpense-a.Rent_Tax__c;
 
   
   
   
    //////////////////Caculate the updated TotalExpenses --> updated PMT1 and PMT2
       BridgeC=a.X2nd_Mtg_Amount__c  +a.X3rd_Mortgage_Amount__c  + a.X4th_Mtg_Amount__c +a.X1st_Writ_Amount__c + 
        a.X2nd_Writ_Amount__c +  a.X3rd_Writ_Amount__c
          +  a.X1st_Caveat_Amount__c  +  a.X2nd_Caveat_Amount__c  +  a.X3rd_Caveat_Amount__c + 
          a.Misc_Expense_1__c  +  a.Misc_Expense_2__c  +  a.Misc_Expense_3__c  +  a.Misc_Expense_4__c
           +  a.Misc_Expense_5__c  +  a.Misc_Expense_6_Amount__c +
           a.Arrears_Estimate__c  +  a.Foreclosure_Legals_Estimate__c +  a.LTV_Insurance__c + 
           a.Taxes__c   + a.Processing_Fee_Bridge_Capital_GIC__c  +
           a.Appraisal__c  +  a.Title_Insurance__c  +  a.Real_Property_Report__c  + 
           a.Renovations_Interior__c  +  a.Renovations_Exterior__c  +  a.Renovations_Extras__c
           +  a.Payout_Penalty_Mortgage_1__c  +  a.Payout_Penalty_Mortgage_2__c  + 
           a.Payout_Penalty_Mortgage_3__c  +  a.Payout_Penalty_Mortgage_4__c    +
           (GrossMonthlyRent-a.Rent_Payoff_Monthly__c)*6 + a.Legal_Fees_Purchase__c + 
           a.Legal_Fees_Purchase_Dispursments__c  +  a.Legal_Fees_Placing_New_Financing__c  +  
           a.Legal_Fees_Placing_New_Fin_Dispursment__c   +  a.Legal_Fees_Sell__c  + 
           a.Legal_Fees_Sell_Dispursment__c  +  a.Investor_Fee_1st_Mortgage__c  + 
           a.Carrying_Costs__c  +  JV_GIC_Consultant_Fee  + 
           JV_GIC_Consultant_Fee  +  a.Reserve_Contingency__c + 
           GrossMonthlyRent*6  + a.Selling_Realtor_Fees__c  +  a.Listing_Realtor_Fees__c;
    BridgeCapitalRoundup=(Decimal)(math.round(BridgeC*1.05/1000))*1000;
       TotalExpenses = a.X1st_Mtg_Amount__c + BridgeC + (BridgeCapitalRoundup/1.05)*(0.03+0.02) ;
 
       If(TotalExpenses <= a.CMA_Property_Value__c*0.75)
       {
        PMT1st = TotalExpenses  * ((0.058 / 12) / (1-math.pow((1+(0.058 / 12)),(-25*12))));
        PMT2nd = 0;
       }
       else
       {
        PMT1st = a.CMA_Property_Value__c*0.75  * ((0.058 / 12) / (1-math.pow((1+(0.058 / 12)) , (-25*12))));
          PMT2nd = (TotalExpenses - a.CMA_Property_Value__c*0.75)* ((0.15 / 12) / (1-math.pow((1+(0.15 / 12)) , (-25*12))));
       }
       ////////////////////
       
       K38=PMT1st+PMT2nd;


       DCR=H42/K38;//line70
       
       if (DCR <= 1.2 && i<20000){
         i++;       
       }else{
        i=0;
       }
       
  }while (i>0);
     

     a.Rent__c=GrossMonthlyRent;
      
       //}//end "for"
   }//end of method

Hi all,

 

My "Lead" has a related list called "Interest". It's a custom object.

 

Interest has a custom field called "isActive". It's a checkbox.

 

What I would like to do are

 -- if isActive is true, that Interest item is shown on the related list.

 -- if isActive is false, that Interest item is not shown on the related list.

 

I know that I can customize what field I show on Lead layout page.

I can choose fields, ex Name,Code,isActive and so on.

 

But I can't find the filtering setting.

 

Is there that setting?

 

If yes, where?

If no, how can I make filtered related list?

 

By VisualForce page?

If so, how can I set on Lead layout page?

 

Thanks,

astraea

Hi,

I am trying to insert a new record to my custom object using the Migration Tool. When deploying my code, the Ant says BUILD SUCCESSFUL however, no record has been added. Below is my code:

==================[build.xml]=========================

"
<project name="Test on TestFund" basedir="." xmlns:sf="antlib:com.salesforce">
   <property file="build.properties"/>
   <property environment="env"/>
    <target name="testInsert">
        <sf:deploy
            username="${sf.username}"
            password="${sf.password}"
            serverurl="${sf.serverurl}"
            deployRoot="InsertTest"/>
    </target>
</project>
"


=================[package.xml]=======================

"
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>lTestFund</members>
        <name>ApexClass</name>
    </types>
    <version>16.0</version>
</Package>
"


=================[lTestFund.cls]=========================

public class lTestFund {

public void loadFund() {
TestFund__c fnd = new TestFund__c(Fund_Name__c='test 2 fund',ISIN__c='KYG000012321');
insert fnd;
}

}

=================[lTestFund.cls-meta.xml]=========================

"
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>lTestFund</members>
        <name>ApexClass</name>
    </types>
    <version>16.0</version>
</Package>
"



Can anyone point to me where causes for not inserting new record?

Thank you.

Regards,
Dellm
Message Edited by Delm on 07-02-2009 11:51 PM
  • July 03, 2009
  • Like
  • 0

Just got done with 'Hello World!' and am working on my second trigger.

 

I seem to be missing something basic. My trigger causes the following error message When I create or edit a new opportunity record:

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger ThankYouTask2 caused an unexpected exception, contact your administrator: ThankYouTask2: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.ThankYouTask2: line 18, column 35

 

 

Here's the code:

 

 

trigger ThankYouTask2 on Opportunity (after insert, after update) { Set<ID> OppIds = new Set<ID>(); for(Opportunity opp : trigger.new){ OppIds.add(opp.Id); } Map<ID, OpportunityContactRole> OppMap = new Map<ID,OpportunityContactRole>([select ContactId, OpportunityId from OpportunityContactRole where IsPrimary = TRUE AND OpportunityContactRole.Id in :OppIds]); List<Task> ThankYous = new List<Task>(); for(Opportunity Opp : trigger.new){ //Construct a task to be added to the ThankYou list Task ty = new Task(); ty.WhatId = Opp.Id; ty.WhoId = OppMap.get(Opp.Id).ContactId; //???????? For new opportunity records the Id is Null... can't be used for-Wait a minute, AFTER INSERT, UPDATE!!!! ty.OwnerId = Opp.Id; ty.Subject = 'Thank You'; ThankYous.add(ty); } insert ThankYous; }

 

 

 

 Anyone with some enlightenment to spare me will be much appreciated!