• sp13
  • NEWBIE
  • 140 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 8
    Likes Received
  • 0
    Likes Given
  • 77
    Questions
  • 38
    Replies
Is it possible to check in the trigger if an IF statement is successful or not?
If I have this code in a before update trigger in Account:
for(Account acc : Trigger.New) {
	if(acc.Name = "Test1") {
		acc.TextField1__c = "Test1";
	} else if(acc.Name = "Test2") {
		acc.TextField1__c = "Test2";
	}
}
the problem here is when Test1 and Test2 fails, I get the error msg. Is there a way to check first in the IF Statement if the Test1 update is successful and if not then it would just go to Test2 until it updates successfully?



 
  • June 18, 2017
  • Like
  • 0
I have Email-to-case enabled and I want the coming emails to retain their HTML format when saved in the new Case record created. I want to save it to a custom Rich text field instead of the standard Description field. How can I achieve this?
  • June 03, 2017
  • Like
  • 1

I have a RichTextField__c that contains text like below:

Dear FirstName,

Please see below for details:
Total: $1000  
<--- I need to get the number "1000" and save it to another custom field. 
 

Thanks,
FirstName


Is there a way for me to get the total amount only "1000" and save it as the value of another custom field using a trigger?

  • June 03, 2017
  • Like
  • 0
Has anyone here encountered this error before: Invalid target field for field update. ?

I have created a SendEmail quick action for Cases with a Predefined Field Value for the ToAddress(formula: Owner.Manager.Email)
I get this error during build when the predefined value is in the metadata. When I try to remove the predefined value in the metadata, the build is successful.

I already checked the fieldPermission for all profiles of the Manager's Email and they all have access to the field. Does anyone know why I'm getting this error?

PS. When I check the metadata of all profiles, I don't see the EmailMessage.ToAddress or any fieldPermission for all EmailMessage fields. Does the EmailMessage fields permission need to be in the profile too? (The EmailMessage fields permission in the target org are editable already)
  • April 19, 2017
  • Like
  • 0
The "Send notification email" checkbox is defaulted to true when using salesforce classic for case ownership change, but not in lightning. The "Notify Case Owners when Case Ownership Changes" setting is set to true in Case Support Setting. Does anyone know why is it not working in lightning?
  • February 16, 2017
  • Like
  • 1
When I try to Change the Owner of a case record in Salesforce Classic, the "Send notification email" checkbox is defaulted to true but when I am trying to Change the Owner in lightning the checkbox is not checked.

The "Notify Case Owners when Case Ownership Changes" is set to true in the Case Support Settings.
  • February 16, 2017
  • Like
  • 0
I need to open the console from an external link.

For example, this link(outside console) automatically redirects to the console:
https://na1.salesforce.com/apex/VFPageName?id=001000000000000
<apex:page controller="VFPageNameController" action="{!GotoConsole}">
</apex:page>
public class VFPageNameController {
    public VFPageNameController() {}

    public Pagereference GotoConsole() {
        PageReference pr = new PageReference('/console?id=' + ApexPages.currentPage().getParameters().get('id'););
        return pr;
    }
}

after I'm redirected to the console, I want the tab of Account record with id 001000000000000 to open automatically. I'm unable to set the primary tab onload of console. Is there a way to do this?
  • June 30, 2016
  • Like
  • 0
How can I use outputURL to redirect to another lightning application?
<aura:iteration items="{!v.AccountsList}" var="acc">
    <ui:outputURL aura:id="oURL" label="{!acc.Name}" value="______"/>
</aura:iteration>
  • May 21, 2016
  • Like
  • 0
How can I access Activities(Tasks and Events) in apex? Should I use web service or is there another way?

I have a VF page in community and need to access Tasks and Events in SOQL but these objects can't be accessed in Community Plus profile.
  • March 08, 2016
  • Like
  • 0
The code below works if you enter/select values on any other fields after entering BODY but if you enter/select values for all the other fields and enter text to the BODY last, it doesn't save / newIdea.Body returns null.
<apex:form>
    <apex:inputField value="{!newIdea.Title}" id="myTitle"/> <!--text field-->
    <apex:inputField value="{!newIdea.Body}" id="newText"/> <!--rich text field-->
    
    <apex:outputPanel id="form2">
        <apex:actionRegion >
            <apex:selectList value="{!selectedPostIdeaLineOfBusiness}" size="1">
                <apex:selectOptions value="{!LineOfBusinessValues}"/>
                <apex:actionSupport event="onchange" reRender="form2"/>
            </apex:selectList>
        </apex:actionRegion>
                                
        <apex:outputPanel rendered="{!selectedPostIdeaLineOfBusiness!=null && selectedPostIdeaLineOfBusiness!='Platform Solutions'}">
            <h2>Device/Channel</h2>
            <apex:selectRadio value="{!selectedPostIdeaDevice}" layout="pageDirection" rendered="{!selectedPostIdeaLineOfBusiness!=null}">
                <apex:selectOptions value="{!DeviceValues}"/>
                <apex:actionSupport event="onchange" reRender="form2, buttonFormId" action="{!validateButton}"/>
            </apex:selectRadio>
        </apex:outputPanel>
                            
        <apex:outputPanel rendered="{!selectedPostIdeaLineOfBusiness!=null}">
            <h2>Solution</h2>
                    <apex:selectRadio value="{!selectedPostIdeaCategory}" layout="pageDirection" rendered="{!selectedPostIdeaLineOfBusiness!=null}">
                        <apex:selectOptions value="{!CategoryValues}"/>
                        <apex:actionSupport event="onchange" reRender="form2, buttonFormId" action="{!validateButton}"/>
                    </apex:selectRadio>
        </apex:outputPanel>
    </apex:outputPanel>
</apex:form> 
                            
<apex:form > 
    <apex:inputFile value="{!newIdea.AttachmentBody}"/>
</apex:form> 

<apex:form id="buttonFormId">
    <apex:commandButton value="Post Idea" reRender="form2" action="{!postNewIdea}" disabled="{!disablePostButton}"/>
</apex:form>

//{!validateButton} == action for checking if all fields are !=null
//{!disablePostButton} == boolean; disable button until all fields are !=null
//{!postNewIdea} == insert newIdea;
  • September 18, 2015
  • Like
  • 0
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();
            }
        }

 
  • September 18, 2015
  • Like
  • 0
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?
  • September 16, 2015
  • Like
  • 0
How to place a placeholder for <apex:inputTextArea richtext="true"/> (richtext enabled)?
  • September 16, 2015
  • Like
  • 0
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

 
  • September 16, 2015
  • Like
  • 0
What is the SOQL for the salesforce standard object Ideas Top All-Time?

I tried [SELECT Id, Title FROM Idea ORDER BY VoteTotal desc], but the results isn't the same as the results from the Ideas Top All-Time tab.
  • September 11, 2015
  • Like
  • 0
Is there a way to disable the Live Chat button in the HTML page or just display the offline button when the queue length is reached?
  • March 27, 2015
  • Like
  • 0
how can i pass a javascript variable to apex variable?
i need to use the apex variable on the if condition for list item class style.

PAGE:
<ul>
    <li class="{!IF(a==true && b==false, 'tabStyle1', 'tabStyle2')}">
        P&amp;L Entry
    </li>
    <li class="{!IF(a==false && b==true, 'tabStyle1', 'tabStyle2')}">
        P&amp;L Search
    </li>
</ul>

<div id="DivID1">
    text1
</div>
<div id="DivID2">
    text2
</div>
<style>
    .tabStyle1 {
        backgroound-color: red;
    }
    .tabStyle2 {
        backgroound-color: blue;
    }
</style>


Controller:
public String a {get;set;}
public String b {get;set;}

public void showA() {
     //a = __________;   <----pass this javascript: $("#DivID1").is(":visible");
     //b = __________;   <----pass this javascript: $("#DivID2").is(":visible");
}



  • July 09, 2014
  • Like
  • 0
I need to show/hide a text(using javascript) depending on the value of variables in apex class
doing alert('{!s1}'); returns correct value but when i pass '{!s1}' to a variable(var var1 = '{!s1}';) it doesn't work.
how can i pass the string from apex class to a javascript variable and use it in if..else statement?

CONTROLLER:
public class SampleCC {
	public String s1 {get;set;}
	public String s2 {get;set;}

	public Sample() {
		s1 = 'true';
		s2 = 'false';
	}
}
Page:
<apex:page controller="SampleCC">
	<script>
		function onloads() {
			var var1 = '{!s1}';
			var var2 = '{!s2}';
			     //alert(var1);  <----this variable returns false even if the value of s1 is true
			if(var1='true' && var2='false') {
				alert('var1 is true, var2 is false');
				$("#one").show();
				$("#two").hide();
			} else {
				alert('var2 is true, var1 is false');
				$("#one").hide();
				$("#two").show();
			}
		}
	</script>
	
	<script type="text/javascript">    
        window.onload=onloads; 
    </script>
	
	<body onload="onload()">
		<div id="one">
			text1
		</div>
		<div id="two">
			text2
		</div>
	</body>
</apex:page>




  • July 09, 2014
  • Like
  • 0
help please. how can i prevent duplication of records based on two fields?
    Objects                          Fields
Schedule__c               
Seat__                            Schedule__c(lookup)
Reservation__c            Seat__c(lookup), Schedule__c(lookup), passenger_name__c

i have this code:
trigger PreventSeatDuplication on Reservation__c (before insert, before update) {

    Map<String, Reservation__c> resMap = new Map<String, Reservation__c>();
   
    for (Reservation__c res : System.Trigger.new) {
  
        if ((res.Seat__c != null) && (System.Trigger.isInsert || (res.Seat__c != System.Trigger.oldMap.get(res.Id).Seat__c))) {
            if (resMap.containsKey(res.Seat__c)) {
                res.Seat__c.addError('Seat not available.');
            } else {
                resMap.put(res.Seat__c, res);
            }
       }
    }
  
    for (Reservation__c res : [SELECT Seat__c FROM Reservation__c WHERE Seat__c IN :resMap.KeySet()]) {
        Reservation__c newRes = resMap.get(res.Seat__c);
        newRes.Seat__c.addError('Seat not available.');
    }
}

but it only prevents the same seat # for the same name, for example, if there is already a record on Reservation__c(Passenger_Name__c='test1', Seat__c='1', Schedule__c='sched001') how can i prevent Reservation__c(Passenger_Name__c='test2', Seat__c='1', Schedule__c='sched001') from saving?
help!
  • March 10, 2014
  • Like
  • 0
hi,
i need to compare the values of list in my apex class to the table cell values in visualforce page.
class:
public List<Seat__c> getAllSeats() {
        return[SELECT Name, taken__c, pending__c FROM Seat__c WHERE Schedule__c = 'a0590000007O6Lu'];
}
vf page:
<table width="500" border="1">
          <apex:variable value="{!AllSeats}" var="r">
                     <tr height="30">  
                                <td width="10%"></td>
                                <td width="5%"> PWD </td>
                                <td width="5%" style="background-color:{!If(r.Name=='1' && r.Taken__c==true,'red',If(r.Name=='1' && r.Pending__c==true,'pink',''))};">
                                  1
                                </td>
                                <td width="5%" style="background-color:{!If(r.Name=='5' && r.Taken__c==true,'red',If(r.Name=='5' && r.Pending__c==true,'pink',''))};">
                                  5
                                </td>
                                <td width="5%" style="background-color:{!If(r.Name=='9' && r.Taken__c==true,'red',If(r.Name=='9' && r.Pending__c==true,'pink',''))};">
                                  9
                                </td>
                                .........
                     </tr>
          </apex:variable>
</table>

the table looks like this:
User-added image

i tried the table cell condition in apex:pageblocktable and it worked fine.
but it didn't work in table tr td
the "AllSeats" values return this values:
User-added image
User-added image
so, the table cell #6 should be color red, and #5 should be pink..
instead it displayed this error:
"Unknown property 'VisualforceArrayList.Name'
Error is in expression '{!If(r.Name=='1' && r.Taken__c==true,'red',If(r.Name=='1' && r.Pending__c==true,'pink',''))}' in component <apex:variable> in page
"

help please.
  • March 08, 2014
  • Like
  • 1
I have Email-to-case enabled and I want the coming emails to retain their HTML format when saved in the new Case record created. I want to save it to a custom Rich text field instead of the standard Description field. How can I achieve this?
  • June 03, 2017
  • Like
  • 1
The "Send notification email" checkbox is defaulted to true when using salesforce classic for case ownership change, but not in lightning. The "Notify Case Owners when Case Ownership Changes" setting is set to true in Case Support Setting. Does anyone know why is it not working in lightning?
  • February 16, 2017
  • Like
  • 1
hi,
i need to compare the values of list in my apex class to the table cell values in visualforce page.
class:
public List<Seat__c> getAllSeats() {
        return[SELECT Name, taken__c, pending__c FROM Seat__c WHERE Schedule__c = 'a0590000007O6Lu'];
}
vf page:
<table width="500" border="1">
          <apex:variable value="{!AllSeats}" var="r">
                     <tr height="30">  
                                <td width="10%"></td>
                                <td width="5%"> PWD </td>
                                <td width="5%" style="background-color:{!If(r.Name=='1' && r.Taken__c==true,'red',If(r.Name=='1' && r.Pending__c==true,'pink',''))};">
                                  1
                                </td>
                                <td width="5%" style="background-color:{!If(r.Name=='5' && r.Taken__c==true,'red',If(r.Name=='5' && r.Pending__c==true,'pink',''))};">
                                  5
                                </td>
                                <td width="5%" style="background-color:{!If(r.Name=='9' && r.Taken__c==true,'red',If(r.Name=='9' && r.Pending__c==true,'pink',''))};">
                                  9
                                </td>
                                .........
                     </tr>
          </apex:variable>
</table>

the table looks like this:
User-added image

i tried the table cell condition in apex:pageblocktable and it worked fine.
but it didn't work in table tr td
the "AllSeats" values return this values:
User-added image
User-added image
so, the table cell #6 should be color red, and #5 should be pink..
instead it displayed this error:
"Unknown property 'VisualforceArrayList.Name'
Error is in expression '{!If(r.Name=='1' && r.Taken__c==true,'red',If(r.Name=='1' && r.Pending__c==true,'pink',''))}' in component <apex:variable> in page
"

help please.
  • March 08, 2014
  • Like
  • 1
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
  • March 07, 2014
  • Like
  • 1
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.
  • March 07, 2014
  • Like
  • 1
is it possible to put the Items to Approve component from Home Tab to a visualforce page? how?
  • February 21, 2014
  • Like
  • 1
how can i insert new records and set a value for the required fields using scheduled job?
these are the objects and its fields:

  Object                              CustomFields
Position__c                  Type(picklist values:admin, tech)
Employee__c               Position__c(lookup)
PaySlip__c                   Employee__c(lookup), Date_From__c, Date_To__c

i want to insert new PaySlip__c records for every Employee whose Position type is 'Tech'
this is the code i'm using to insert new PaySlip__c and fill up the Date_From__c and Date_To__c
global class autoGenerateReport implements Schedulable {
         global void execute(SchedulableContext arc) {
                  Date dateToday = system.Today();
                  Integer month = dateToday.month();
       
        Integer year = dateToday.year();
       
                  Date firstDayOfMonth = System.today().toStartOfMonth();
                  Date firstOfMonth = date.newinstance(year, month, 1);
                  Date upToDate = date.newinstance(year, month, 15);
       
                  PaySlip__c createReport = new PaySlip__c();
                  createReport.Date_From__c = firstOfMonth;
                  createReport.Date_To__c = upToDate;
       
                   insert createReport;
         }
}

  • February 06, 2014
  • Like
  • 1
i have a checkbox field Checkbox1__c and two text fields TextField1__c and TextField2__c
this validation rule doesn't work: IF( Checkbox1__c== false, TextField1__c= null && TextField2__c= null, TextField1__c= null && TextField2__c= null)

i want to create a validation rule that when Checkbox1__c is unchecked, the TextField1__c and TextField2__c should have no values. help ?
  • January 24, 2014
  • Like
  • 1
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();
            }
        }

 
  • September 18, 2015
  • Like
  • 0
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?
  • September 16, 2015
  • Like
  • 0
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

 
  • September 16, 2015
  • Like
  • 0
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
  • March 07, 2014
  • Like
  • 1
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.
  • March 07, 2014
  • Like
  • 1
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?
  • March 05, 2014
  • Like
  • 0
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;
        }
    }
}
  • February 19, 2014
  • Like
  • 0
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?
  • February 17, 2014
  • Like
  • 0
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?
  • February 16, 2014
  • Like
  • 0
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?
  • February 13, 2014
  • Like
  • 0
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?
  • January 07, 2014
  • Like
  • 0
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>

  • January 02, 2014
  • Like
  • 0