• sp13
  • NEWBIE
  • 140 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 8
    Likes Received
  • 0
    Likes Given
  • 77
    Questions
  • 38
    Replies
the onblur works fine in chrome but doesn't work in Iinternet Explorer
 
<apex:inputField onfocus="displayPlaceholder();" value="{!newIdea.Title}" id="myTitle" onblur="checkNextFocus();">

      <div id="bodyPlaceholder" onclick="newBodyPlaceholder();"> 
          What problem does this solve?
          <br/><br/><br/>
          What is the business case?
      </div> 


//script
        console.log('START: newBodyPlaceholder()');
        function newBodyPlaceholder() {
            document.getElementById("bodyPlaceholder").style.display = "none";
        }
        
        console.log('START: displayPlaceholder()');
        function displayPlaceholder() {
            document.getElementById("bodyPlaceholder").style.display = "block";
        }
        
        console.log('START: checkNextFocus()');
        function checkNextFocus() {
            if(document.activeElement.nodeName.toUpperCase() == 'BODY') {
                newBodyPlaceholder();
            }
        }

 
The <apex:inputTextArea richtext="true"/> allows me to upload image by entering the image link:
User-added image

What I need is to be able to upload image from local folder like this:
User-added image


How can I add this to the inputTextArea?
I have a field TotalContacts__c which has the total numbers of contacts of each account. I need to query all contacts ordered by the total number of contacts [SELECT Name FROM Account ORDER BY TotalContacts__c DESC] but I also need to order them by which has the latest contact.

For example, if Account 1, Account 2 and Account 3 all has 5 TotalContacts__c, then I need them to be ordered by which one has the lastest related contact.
 example:
Account Name   TOtalContacts__c   (last contact related to account is created on:
Account 1                       5                            08/20/2015
Account 3                       5                            08/18/2015
Account 2                       5                            07/30/2015

 
my custom currency field shows the right format in the detailed page like this: $1,000.00
but when i called the field in visualforce page it displayed like this: 1000.00
it's fine for me not to display the '$' sign but i need the comma, how?
help
i created this table in my visualforce page with this code:
<table width="500" border="1">
   <tr height="30">  
     <td width="10%"></td> <td width="5%"> PWD </td> <td width="5%"> 1 </td> <td width="5%"> 5 </td> <td width="5%"> 9 </td>
     <td width="5%"> 13 </td> <td width="5%"> 17 </td> <td width="5%"> 21 </td> <td width="5%"> 25 </td> <td width="5%"> 29 </td>
     <td width="5%"> 33 </td> <td width="5%"> 37 </td> <td width="5%"> 41 </td> <td width="5%"> 45 </td>
     <td width="5%"> 49 </td> <td width="5%"> 53 </td> <td width="5%"> 57 </td> <td width="5%"> 61 </td>
   </tr>
   <tr height="30">  
     <td width="10%"></td><td width="5%"> PWD </td> <td width="5%"> 2 </td> <td width="5%"> 6 </td>
     <td width="5%"> 10 </td> <td width="5%"> 14 </td> <td width="5%"> 18 </td> <td width="5%"> 22 </td>
     <td width="5%"> 26 </td> <td width="5%"> 30 </td> <td width="5%"> 34 </td> <td width="5%"> 38 </td>
     <td width="5%"> 42 </td> <td width="5%"> 46 </td> <td width="5%"> 50 </td> <td width="5%"> 54 </td>
     <td width="5%"> 58 </td> <td width="5%"> 62 </td>
   </tr>
   <tr height="30">  
     <td colspan="17"></td> <td width="5%"> 63 </td>
   </tr>
   <tr height="30">  
     <td width="10%"></td> <td width="5%"> Driver's Seat </td> <td width="5%"> 3 </td> <td width="5%"> 7 </td>
     <td width="5%"> 11 </td> <td width="5%"> 15 </td> <td width="5%"> 19 </td> <td width="5%"> 23 </td>
     <td width="5%"> 27 </td> <td width="5%"> 31 </td> <td width="5%"> 35 </td> <td width="5%"> 39 </td>
     <td width="5%"> 43 </td> <td width="5%"> 47 </td> <td width="5%"> 51 </td> <td width="5%"> 55 </td>
     <td width="5%"> 59 </td> <td width="5%"> 64 </td>
   </tr>
   <tr height="30">  
     <td width="10%"></td> <td width="5%"> Driver's Seat </td> <td width="5%"> 4 </td> <td width="5%"> 8 </td>
     <td width="5%"> 12  </td> <td width="5%"> 16 </td> <td width="5%"> 20 </td> <td width="5%"> 24 </td>
     <td width="5%"> 28 </td> <td width="5%"> 32 </td> <td width="5%"> 36 </td> <td width="5%"> 40 </td>
     <td width="5%"> 44 </td> <td width="5%"> 48 </td> <td width="5%"> 52 </td> <td width="5%"> 56 </td>
     <td width="5%"> 60 </td> <td width="5%"> 65 </td>
   </tr>
</table>

 
CLASS:
public List<Seat__c> seat {get;set;}
//controller//
seat = [SELECT Id, Name FROM Seat__c WHERE (Taken__c=true and Pending__c=true) and Schedule__c = 'a0590000007O6Lu']


i need the table cell color to be red if the reservation with a seat number is taken and color yellow if pending.
for example, if seat number 1 is taken i want the table cell background color with the value of '1' to be red or yellow if it's pending.
help.
i have a visual for page that include this:
<apex:inputField value="{!reserve.Mode_of_Payment__c}" required="true">
          <apex:actionSupport event="onchange" reRender="page"/>
</apex:inputField>
<apex:inputField value="{!reserve.Credit_Card_Number__c}" rendered="{!reserve.Mode_of_Payment__c='Credit Card'}"/>
<apex:inputField value="{!reserve.Your_Smart_Money_Number__c}" rendered="{!reserve.Mode_of_Payment__c='Smart Money'}" label="Smart Money Transaction #"/>
<apex:inputField value="{!reserve.Amount_Paid__c}" required="true"/>
<apex:commandButton value="Pay" action="{!pay}" style="padding: 5px 25px;"/>

i added/enabled this visualforce page to my site domain: http://elavil-developer-edition.ap1.force.com/sitepage/OnlinePayment
it should display like this:
User-added image
instead, it displays like this:
User-added image

all of these fields are visible when i open/view it as an administrator. why is it that when i go to my site domain(http://elavil-developer-edition.ap1.force.com/sitepage/OnlinePayment) the fields doesn't show? can anyone help me please?
hi! how can i group records shown in custom chart?
i created a custom chart in visalforce page.
it looks like this:
User-added image
this is from the list of records in Expense__c object
User-added image
i need the pie chart to show the largest part for Buses=P1000
how can i group these records?

here is my code:
VF:
<apex:page controller="ChartsCC" title="Pie Chart">
        <apex:chart height="350" width="450" data="{!pieData}">
            <apex:pieSeries dataField="data" labelField="name"/>
            <apex:legend position="bottom"/>
        </apex:chart>
</apex:page>

APEX CLASS:
public with sharing class ChartsCC {
    public List<PieChartData> getPieData() {
             List<PieChartData> data = new List<PieChartData>();
             for (Expense__c exp : [SELECT Type_of_Expense__c FROM Expense__c]) {
                      data.add(new PieChartData(exp.Type_of_Expense__c, 20));
             }       
             return data;
    }
    public class PieChartData {
        public String name { get; set; }
        public Decimal data { get; set; }
        public PieChartData(String name, Decimal data) {
                 this.name = name;
                 this.data = data;
        }
    }
}
how can i schedule this code yearly?
i want it to run every January 1 at 12am
global class autoCreateIS implements Schedulable {
         global void execute(SchedulableContext arc) {
                    Date dateToday = system.Today();
                    Integer year = dateToday.year();
                    Integer nextYear = (year + 1);
       
                    IS__c createIS = new IS__c();
                    createIS.Name = String.valueOf(nextYear);
                    insert createIS;
         }
}

when i go to Apex Classes > Schedule Apex, the only choices are weekly and monthly
what if i only want it to run yearly?
i have a visualforce page to search for records whose date is equal to the selected date in visualforce page.
how can i create a custom date field in vf page?

i have an object Schedule__c with a custom DateTime field Date_Time__c

i want to have a date field in the visualforce page to use for searching. is it possible?
how can i update a record in my visualforce page table?
my table is like this:
Name        UnitPrice(inputfields)            Link
Fuel1                  50.00                        Update Price
Fuel2                  60.00                        Update Price

this is my vf page:
<apex:page showHeader="false" sidebar="false" standardController="Fuel__c" extensions="FuelUpdateCX">
    <apex:form >
        <apex:messages />
        <apex:pageBlock >
            <apex:pageBlockTable value="{!Fuel}" var="f">
                <apex:column value="{!f.Name}"/>
                <apex:column headerValue="Unit Price">
                    <apex:inputField value="{!f.Unit_Price__c}"/>
                </apex:column>
                <apex:column width="10%">
                    <apex:commandLink action="{!updatePrice}" style="padding:1px 2px; font-weight:bold;">Update Price</apex:commandLink>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

and this is the class:
public with sharing class FuelUpdateCX {
    public FuelUpdateCX(ApexPages.StandardController controller) {}
    public List<Fuel__c> getFuel() {
            return[select id, Name, Unit_Price__c from Fuel__c ORDER BY Name];
    }
    public pageReference updatePrice() {
        //update fuel here
        return new PageReference('/apex/FuelUpdate');
    }
}
should i use wrapper? how can i update the price here?
these are my objects:
       Object                              Field
Reservation__c          Seat__c(lookup)
     Seat__c                Taken__c(checkbox)
i need to update Taken__c whenever a new record of Reservation__c is created or updated.
 
i tried this code but didn't work:
trigger updateSeatTaken on Reservation__c (before insert, before update, after insert, after update) {
    for (Reservation__c r : trigger.new) {
           Seat__c takenSeat = [select name, taken__c from Seat__c where id =: r.id];     
                   r.Seat__r.Taken__c = true;
                   update r;
    }
}

an error showseverytime i create or update a Reservation__c record:
Apex trigger updateSeatTaken caused an unexpected exception, contact your administrator: updateSeatTaken: execution of BeforeInsert caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.updateSeatTaken: line 3, column 1

any help?
i have a problem saving multiple records at a time. i think the problem is in the saveSeats() i just don't get it. the data display fine in the pageblocktable but it doesn't save when i click the save button. any idea what's the problem here? please help.

Apex Class:
public with sharing class NewScheduleSeatsCX {
    List<Seat__c> seatList = new List<Seat__c>();    //saving seat records
    public List<SeatsWrapper> wrappers {get;set;}        //wrapperlist
    public List<Integer> numberOfSeats {get;set;}
   
    public Schedule__c sd {get;set;}
    public Schedule__c schedule {
      get {
        if (schedule == null)
          schedule = new Schedule__c();
        return schedule;
      }
      set;
    }

    public NewScheduleSeatsCX(ApexPages.StandardController controller) {
        wrappers = new List<SeatsWrapper>();
        numberOfSeats = new List<Integer>();
      
        sd=[select id, name, Number_Of_Seats__c from Schedule__c where id =: apexPages.currentPage().getParameters().get('id')];
        for(integer i=1;i<=sd.Number_Of_Seats__c; i++){
            SeatsWrapper temp = new SeatsWrapper();
            temp.seatNum = i;
            temp.seat = new Seat__c();
            wrappers.add(temp);
        }
    }
  
/**************    Wrapper    *************/
    public class SeatsWrapper {
 public Seat__c seat {get;set;}
 public Integer seatNum {get;set;}
    }
/**************    /Wrapper    *************/

//------------------------------   Save Seats     ------------------------------//
    public pageReference saveSeats() {
        try {
            for(SeatsWrapper  s : wrappers ) {
                    Seat__c newSeats = new Seat__c();
   
                    String seatName = newSeats.Name;
                    Integer sN = Integer.valueOf(seatName);
                   
                    sN = s.seatNum;
                    newSeats.Schedule__c = schedule.Id;
                    newSeats.Taken__c = s.seat.Taken__c;
                   
                    seatList.add(newSeats);
                }
                insert seatList;            //save all seats
          
        } catch(Exception e) {
            apexPages.addMessages(e);
        }
        return null;
    }
//------------------------------   /Save Seats     ------------------------------//
}

VF Page:
               <apex:pageBlockTable value="{!wrappers}" var="sched">
                         <apex:column headerValue="Seat #" style="padding: 0px 20px;">
                                     <apex:outputText value="{!sched.seatNum}"/>
                         </apex:column>
                         <apex:column headerValue="Taken" style="padding: 0px 20px;">
                                     <apex:inputField value="{!sched.seat.Taken__c}"/>
                         </apex:column>
                </apex:pageBlockTable>