• Laytro80
  • NEWBIE
  • 50 Points
  • Member since 2009

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

Hello,

 

I have created a new HTML e-mail, but when i click preview, there are no spaces, it is all running together. The Text version is fine. Please Help!!

 

Smiller

  • September 09, 2010
  • Like
  • 0

Hi Simon,

 

Quick question.

 

Do you think it would be possible (I don't mean you, unless you have lots of free time :-) ) to have a trapdoor iPad application.

 

I am using my iPad more and more for salesforce.com, it's just a pain not having the brilliant trapdoor application to log-in quickly.

 

Cheers

 

R

I got a lot of help from people on this one a few months back so thanks to all.  Testing has gone well, I have made some changes and I am ready to push into live.

 

I now need to write a test script and I have no idea how to begin.  Any code snippets / pointers would be helpful. I rarely have to write APEX code but had not choice on this occasion.  Thanks again

 

 

public class Roommanager {
    public void search() {
        // Provide default values in the event that no dates are selected
        if(room.Search_Start_Date__c==null)
            room.Search_Start_Date__c=System.today().toStartOfMonth();        
        if(room.Search_End_Date__c==null)
            room.Search_End_Date__c=System.today().toStartOfMonth();    
        
        // Swap the dates if start is before end
        if(room.Search_Start_Date__c>room.Search_End_Date__c) {
            Date tempDate = room.Search_Start_Date__c;
            room.Search_Start_Date__c = room.Search_End_Date__c;
            room.Search_End_Date__c = tempDate;
        }
        
        // Remove previous search results
        rooms.clear();
        availableRooms.clear();
        
        // Find all the room allocations, add them to the list
        rooms.addAll(
            [SELECT
                Id, Name, Start_Date__c, End_Date__c, Nights__c, Room__c, Room__r.Room_No__c, Room__r.Lodge__c, Reservation__c, Reservation__r.Reservation_Contact__c
            FROM
                Room_Allocation__c r     
            WHERE (
                (Start_Date__c >= :room.Search_Start_Date__c  AND Start_Date__c <= :room.Search_End_Date__c) OR
                (End_Date__c  >= :room.Search_Start_Date__c  AND End_Date__c  <= :room.Search_End_Date__c) OR
                (Start_Date__c <= :room.Search_Start_Date__c  AND End_Date__c  >= :room.Search_End_Date__c))  
            ORDER BY
                Room__r.Lodge__c ASC,Room__r.Room_No__c ASC, Room__r.Lodge__c ASC]);
        
        // Build a list of allocated rooms
        Set<Id> allocatedRooms = new Set<Id>();
        for(Room_Allocation__c roomAlloc:rooms)
            allocatedRooms.add(roomAlloc.Room__c);
        
        // Add the rooms that are still available
        availableRooms.addAll(
            [SELECT
                Id, Name, Room_No__c, Lodge__c, Doubles__c, Singles__c, Style__c, Normal_PAX__c,
                (SELECT
                    Id, Name, Start_Date__c, End_Date__c, Room__c
                FROM
                    Room_Allocations__r)
            FROM
                Room__c
            WHERE
                Id NOT IN :allocatedRooms
            ORDER BY
                Lodge__c ASC, Room_No__c ASC]
        );
    }

    public Room_Allocation__c room;
    
    public List<Room_Allocation__c> rooms { get; set; }
    public List<Room__c> availableRooms { get; set; }
    
    // Constructor initialize memory variables
    public Roommanager(ApexPages.StandardController controller) {
        room=(Room_Allocation__c)controller.getRecord();
        rooms=new List<Room_Allocation__c>();
        availableRooms = new List<Room__c>();
        // Default search.
        search();           
    }
}

 

 

I have a custom object which has a start and an end date. I want to write some code which will search to see if any record occurs within those dates - easy.

 

But I also want some code that check to show any overlapping records. So for example if I search to see if records exists between the 1st March and the 30 March I want it to return all of the records below because they either fall within the search or overlap.

 

a. Record -  with a start date of 2 March and and end date of the 29 March

b. Record - with a start date of the 1st Feb and an end date of the 28 March

c. Record - with a start date of the 2nd March and an end date of the 28 April

d. Record - with a start date of the 1st Jan and an end date of the 30 April

 

Be great to get some help on this one as I am a bit stuck

Hi Simon,

 

Hope you are well.

 

Have a problem on a friends Mac they are using Maildrop (latest version).

 

Using Mac Office Outlook 2011 the email is going into the system with so strange characters.

 

Email extract Salesforce via Maildrop, any thoughts thanks as always

 

v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}st1\:*{behavior:url(#default#ieooui) }

FYI &#8211; now 4 pax in the Solomongroup so Simon Manuel will share the twin room with Danny. 
Can you please confirm the rooming listwith the accommodation, and also ensure that the car we have booked is bigenough for 4 clients, a guide, plus luggage (we would not want to have 3clients sitting in the back seat, so it probably needs to be a 7 seater.

I&#8217;ll let you know asap about theferry for Ben on the 22nd &#8211; it looks like he may be able totravel back to Ullapool on the 2.30pm ferry, so he would not need accomm inStornoway that night. I&#8217;ll confirm asap when I hear back from Danny rewhat time he needs dropped off at the airport that day.

 

I am sure this is a simple error,  code snippet below.

 

When I hit save the url of the apex page stays within the browser address bar.

 

Just can't see what I am doing wrong.

 

 

   public PageReference save() {
        insert slots;
        PageReference home = new PageReference('/a00/o');
        home.setRedirect(true);
        return home;
    }

 

 

Hi,

 

Have two problems.

 

1.  When the visualforce page below runs it saves in downloads with no association to excel.  I am guessing the content type is wrong but I have not found the right one.

 

2.  When I manually add the .xls extension and open in excel the name field (code highlighted in red) has some strange data.

 

Thanks

 

Ross

 

 

 

<apex:page standardController="Trip__c" cache="true" contenttype="application/vnd.ms-excel" showHeader="false">
    <h1>TRIP DETAILS</h1>
    <p></p>
    <br></br> 
    <apex:dataTable value="{!Trip__c}" var="T" id="TripTable" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!T.Name}" headerValue="Trip Code"/>
                <apex:column value="{!T.Trip_Title__c}" headerValue="Trip Title" />
                <apex:column value="{!T.Start_Date__c}" headerValue="Start Date"/>
                <apex:column value="{!T.End_Date__c}" headerValue="End Date"/>                       
    </apex:dataTable>
    <p></p>
    <br></br>
    <H1>GUIDE</H1> 
    <br></br>  
    <p></p>  
         <apex:dataTable value="{!Trip__c.Guides__r}" var="G" id="Guide" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!G.Guide__r.Name}" headerValue="Guide Name"/>
                <apex:column value="{!G.Guide__r.MobilePhone}" headerValue="Mobile"/>
                <apex:column value="{!G.Guide__r.Dietary_Requirements__c}" headerValue="Diet"/>
                <apex:column value="{!G.Guide__r.Medical_Conditions__c}" headerValue="Medical"/>                                     
        </apex:dataTable>
    <p></p>
    <br></br>    
    <H1>VEHICLES</H1>
    <br></br> 
    <p></p>     
        <apex:dataTable value="{!Trip__c}" var="O" id="Vehicles" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!O.Vehicles__c}" headerValue="Vechicles"/>  
        </apex:dataTable>
    <p></p>
    <br></br> 
    <H1>BOOKING DETAILS</H1>
    <br></br> 
    <p></p>   
    <apex:dataTable value="{!Trip__c.Travellers__r}" var="B" id="BookingTable" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!B.Traveller__r.Name}" headerValue="Traveller"/>
                <apex:column value="{!B.Traveller__r.Birthdate}" headerValue="DOB"/>                
                <apex:column value="{!B.Traveller__r.Total_Number_of_Trips__c}" headerValue="Number of Trips"/>
                <apex:column value="{!B.Traveller__r.Dietary_Requirements__c}" headerValue="Diet"/>
                <apex:column value="{!B.Traveller__r.Medical_Conditions__c}" headerValue="Medical"/>
                <apex:column value="{!B.Traveller__r.Chest_Size__c}" headerValue="Chest"/>
                <apex:column value="{!B.Traveller__r.Hand__c}" headerValue="Hand"/>
                <apex:column value="{!B.Traveller__r.Height__c}" headerValue="Height"/>
                <apex:column value="{!B.Traveller__r.MobilePhone}" headerValue="Mobile"/>
                <apex:column value="{!B.Traveller__r.Emergency_Contact__c}" headerValue="Emergency Contact"/>
                <apex:column value="{!B.Traveller__r.Emergency_Number__c}" headerValue="Emergency Number"/>
                <apex:column value="{!B.Cancelled_Formula__c}" headerValue="Cancelled"/>                
    </apex:dataTable>
    <p></p>
    <br></br>
    <H1>TRAVELLER NOTES</H1>
    <br></br>   
    <p></p>  
         <apex:dataTable value="{!Trip__c.Travellers__r}" var="TN" id="TripNote" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!TN.Traveller__r.Name}" headerValue="Traveller"/>
                <apex:column value="{!TN.Traveller__r.MailingCountry}" headerValue="Country of Residence"/>            
                <apex:column value="{!TN.Equipment__c}" headerValue="Equipment"/>
                <apex:column value="{!TN.Traveller_Notes__c}" headerValue="Notes"/>                                                     
        </apex:dataTable>
    <p></p>
    <br></br>
    <H1>ACCOMMODATION DETAILS</H1>  
    <br></br> 
    <p></p>  
    <apex:dataTable value="{!Trip__c.Rooms__r}" var="R" id="RoomTable" headerClass="tablehead" columnClasses="tabledata">   
                <apex:column value="{!R.Accommodation__r.Name}" headerValue="Accommodation Name"/>
                <apex:column value="{!R.Accommodation__r.Accommodation_Phone__c}" headerValue="Phone Number"/>
                <apex:column value="{!R.Accommodation__r.Start_Date__c}" headerValue="Start Date"/>
                <apex:column value="{!R.Accommodation__r.End_Date__c}" headerValue="End Date"/>
                <apex:column value="{!R.Accommodation__r.Nights__c}" headerValue="Nights"/>
                <apex:column value="{!R.Room_Type__c}" headerValue="Room Type"/>             
                <apex:column value="{!R.Occupant_1__r.Name}" headerValue="Occupant 1"/>
                <apex:column value="{!R.Occupant_2__r.Name}" headerValue="Occupant 2"/>
                <apex:column value="{!R.Occupant_3__r.Name}" headerValue="Occupant 3"/>
                <apex:column value="{!R.Occupant_4__r.Name}" headerValue="Occupant 4"/>                
                <apex:column value="{!R.Room_Note__c}" headerValue="Room Note"/>        
    </apex:dataTable>
    <p></p>
    <br></br>       
    <H1>TRIP NOTES</H1> 
    <br></br>     
        <apex:outputText value="{!Trip__c.Trip_Notes__c}"></apex:outputText>
    <p></p>
    <br></br> 
</apex:page>

 

 

Hi, I have had a lot of help to get this far, thanks to all concerned.

 

Background

 Below is some code to a VF page and an APEX controller.  The idea is somebody puts a start and an end date into a input form on a VF page and hits search. You are then shown all the booked rooms (allocated rooms) and the un-booked rooms in 2 separate lists.

 

Problem  - (Dates are shown in the dd/mm/yyyy format)

I need to show bookings that fall within the search criteria but might be outside of the start and end dates.  For example I have a room allocated with a start date of the 10/3/2011 and end date of 15/4/2011.

 

If I search to show bookings starting on the 20/3/2011 and ending on the 31/03/2011 using the code below the above example will not show. But I need it to as you can see the allocated room has some dates (i.e 20/3, 21/3, 22/3,24/3,etc...) occurring between these dates.

 

Possible Solution

First I think I need to list each room allocation.  Then list all the dates that occur on and between the start and end date. Then using the search start and end date list all the dates between these two dates. The cross reference both lists to see if one of the listed dates exists in both lists and return the record.  

 

But I have no idea if this is correct or how to take it forward.

 

Code

 

VF Page

 

 

<apex:page standardController="Room_Allocation__c"  extensions="Roommanager" tabStyle="Room_Availability_Search__tab">
    <apex:form >
    
        <apex:sectionHeader title="Room Availability Search"/>
                    
            <apex:pageBlock title="Search">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!room}" value="Search"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!room.Search_Start_Date__c}"/>
                    <apex:inputField value="{!room.Search_End_Date__c}"/> 
                </apex:pageBlockSection>
            </apex:pageBlock>  
            
            <apex:pageBlock title="Booked Rooms">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!rooms}" var="room">
                        <apex:column value="{!room.Room__r.Lodge__c}"  />
                        <apex:column value="{!room.Room__r.Room_No__c}"  />
                        <apex:column value="{!room.Room__c}"  />
                        <apex:column value="{!room.Name}"  />                        
                        <apex:column value="{!room.Start_Date__c}"  />
                        <apex:column value="{!room.End_Date__c}"  />
                        <apex:column value="{!room.Nights__c}"  />
                        <apex:column value="{!room.Reservation__c}"  />   
                        <apex:column value="{!room.Reservation__r.Reservation_Contact__c }"  />                         
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock> 

            <apex:pageBlock title="Available Rooms">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!availablerooms}" var="avail">
                        <apex:column value="{!avail.Lodge__c}"  />
                        <apex:column value="{!avail.Room_No__c}"  />
                        <apex:column value="{!avail.Name}"  />                        
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock>             
            
            
    </apex:form>
</apex:page>

 

 

 

 

 

APEX Controller

Public class Roommanager {

    public PageReference room() {
        return null;
    }
    
    public List<Room_Allocation__c> listBd; 

    public Room_Allocation__c room {get;set;}
    public Roommanager(ApexPages.StandardController controller) {
           room=(Room_Allocation__c)controller.getRecord();
             }
            
    public List<Room_Allocation__c> getRooms(){

            listBd=[select Id, Name, Start_Date__c, End_Date__c, Nights__c, Room__c, Room__r.Room_No__c, Room__r.Lodge__c, Reservation__c, Reservation__r.Reservation_Contact__c from Room_Allocation__c r 
                where (Start_Date__c >= :room.Search_Start_Date__c 
                    and 
                    Start_Date__c <= :room.Search_End_Date__c
                    )
                    or
                    (End_Date__c >= :room.Search_Start_Date__c
                    and
                    End_Date__c <= :room.Search_End_Date__c)
                    ORDER BY Room__r.Lodge__c ASC,Room__r.Room_No__c ASC, Room__r.Lodge__c ASC];  
            
             return listBd;
 }

public List<Room__c> getAvailableRooms()
{
if(listBd == null || listBd.size() == 0)
getRooms();

List<Id> allocatedRooms = new List<Id>();

for (Room_Allocation__c roomAlloc : listBd)
allocatedRooms.add(roomAlloc.Room__c);

return ([Select Id, Name, Room_No__c, Lodge__c,(Select Id, Name, Start_Date__c, End_Date__c, Room__c from Room_Allocations__r) from Room__c where Id NOT IN :allocatedRooms ORDER BY Lodge__c ASC, Room_No__c ASC]);

} 
}

 

 

 

 

 


Below is my code which works on a custom lead object.  The work I am doing is on a force.com org which does not have the standard lead object.  On the custom lead object I have a check box called convert.  When checked a trigger fires and using the data contained in the lead it creates a contact and an account.

 

Problem 1 - I want to link the account and contact but I can't get it to work, I guess it's because the account is not yet created

 

Problem 2 - Instead of checking the tick box I would instead like a detail page button when clicked it would fire the trigger below

 

 

trigger ConvertTrigger on fp_lead__c (after insert, after update) {
System.Debug('## >>> Trigger executing run by ' + UserInfo.getName());

    fp_lead__c[] myLeadsToProcess = new fp_lead__c[]{};
    for(Integer i=0 ; i<Trigger.new.size() ; i++) {
        if (  Trigger.new[i].convert__c == true ) {
           
            myLeadsToProcess.add(Trigger.new[i]);  // build list of recs to process
   
        }
    }
    if(myLeadsToProcess.size()>0){

        Contact[] myNewContact = new Contact[]{};
        Account[] myNewAccount = new Account[]{};

        for (fp_lead__c myLead : myLeadsToProcess) {
        
            Account act = new Account();
            act.name = myLead.company__c;
            act.website = myLead.website__c;
            myNewAccount.add(act);

            Contact con = new Contact();
            con.firstname = myLead.First_Name__c;
            con.lastname = myLead.Last_Name__c;            
            con.phone = myLead.Phone__c;
            con.mobilephone = myLead.Mobile__c;
            con.fax = myLead.Fax__c;
            con.email = myLead.Email__c;
            con.title = myLead.Title__c;
            con.salutation = myLead.Salutation__c;
            myNewContact.add(con); 
           
            }     
            insert myNewContact;
            insert myNewAccount;
        }
   
System.Debug('## >>> Trigger END <<<');
}

 

 

Hi,

 

Struggling on this, I would like a custom list view with a dynamic date field search.  Below is a visualforce page which is all set-up just how I want it. I am using the action save clearly this needs to be a search method.

 

 

<apex:page standardController="Reservation__c"  extensions="Resmanager">
    <apex:form >
        <apex:sectionHeader title="Availability Search"/>            
            <apex:pageBlock title="Search">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{save}" value="Search"/>
                </apex:pageBlockButtons>
                <apex:inputField value="{!Reservation__c.Start_Date__c}"/>
            </apex:pageBlock>  
            <apex:pageBlock title="Reservations">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        <apex:column value="{!res.Nights__c}"  />
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock> 
    </apex:form>
</apex:page>

 

I am not sure how to write the search method, my attempt on the controller below.  I am hardcoding yesterday to get the controller to work.

 

 

public class Resmanager { 

    public Resmanager(ApexPages.StandardController controller) {

    }
        
    public List<Reservation__c> getReservations(){
        List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where start_date__c = yesterday];
        return listBd;   
    }
   
}

 

 

 

Below is a simple VF page and Controller. You will not on the Controller I hard code the

 

 

where nights__c = 4

 

 I want to make this dynamic using a input field on the VF page.

 

 

 

VF Page

 

 

<apex:page controller="Resmanager">
    <apex:sectionHeader title="Availability Search"/> 
                 
              <apex:pageBlock title="Reservations">
              <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        <apex:column value="{!res.Nights__c}"  />
                    </apex:pageBlockTable>
               </apex:pageBlockSection>
               
               </apex:pageBlock>

</apex:page>

 

 

APEX Controller

 

 

public class Resmanager {
    
    public List<Reservation__c> getReservations(){
        List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where nights__c = 4];
        return listBd;   
    }
   
}

 

 

 

Hi,

 

I have need to roll up data from one object to another but cannot use a master detail relationship.

 

I have an object called project and an object called time sheet.

 

When a timesheet is created and linked to project I want to sum all related time sheet records.

 

I would usually use a master detail relationship but I can't lock timesheet to project as timesheets can be agains most objects.

 

Is there an easy way every time a time sheet is added to project to have a field - total time spent calculate?

 

Thanks

 

Ross

Suspect this is a simple problem, but I can't see the wood for the trees.

 

I have two objects booking__c and traveller__c. When you create a booking record you have to enter a lead contact (lookup to contact) and then when you hit save you then add the travellers which appears as a related list on the booking record.

 

The first traveller is always the lead contact.  The traveller record only has two fields the booking and the traveller (lookup to contact).  So I was hoping to automatically create a traveller record as I have the booking record has the two ids needed.

 

I can successfully create a traveller record automatically linked to the booking without a traveller.  It's only when I try to add the traveller (lookup to contact) I run into problems.

 

I have highlight in red the problem line. Have tried a few things like adding .id.

 

 

public class newBookingController {
    
   Booking__c booking;
   Traveller__c traveller;
    
   public Booking__c getBooking() {
      if(Booking == null) Booking = new Booking__c();
      return booking;
   }

   public Traveller__c getTraveller() {
      if(Traveller == null) Traveller = new Traveller__c();
      return Traveller;
   }
    
   public PageReference step1() {
      return Page.bookStep1;
   }

   public PageReference step2() {
      return Page.bookStep2;
   }

   public PageReference step3() {
      return Page.bookStep3;
   }
    
    public PageReference cancel() {
            PageReference bookingPage = new ApexPages.StandardController(booking).view();
            bookingPage.setRedirect(true);
            return bookingPage; 
    }
    
   public PageReference save() {
    
      insert booking;
      
      traveller.traveller__c = booking.lead_contact__c;
      traveller.booking__c = booking.id;      
      insert traveller;

      PageReference bookingPage = new ApexPages.StandardController(booking).view();
      bookingPage.setRedirect(true);
      return bookingPage; 
   }

}

 

 

Any suggestions welcome.

 

Thanks

 

Ross

Hi,


I have a master object called Expense Form and a child object called Expense Item.  I trying to create a wizard which will allow me to save multiple expense item records against an expense form object.  With some help I have gotten this far, I have highlighted in red the part which I think is wrong.


With this code I am getting the following error:  Expression cannot be assigned at line -1 column -1.


Any help would be great.

 

 

public class newExpensesController {
    
   Expense_Form__c Eform;   
   Expense_Item__c Eitem;
    
   public Expense_Form__c getEform() {
      if(Eform == null) Eform = new Expense_Form__c();
      return Eform;
   }
   
   public Expense_Item__c getEitem() {
     if(Eitem == null) Eitem = new Expense_Item__c();
     return Eitem;
   } 
    
    public PageReference cancel() {
            PageReference EformPage = new ApexPages.StandardController(Eform).view();
            EformPage.setRedirect(true);
            return EformPage; 
    }
    
    public PageReference save() {   
      List<Expense_Form__c> Eitems=new List<Expense_Form__c>();
      for (Expense_Form__c Eform : Eform)
      {
         Expense_Item__c Eitem=newEitems (Expense_Form__c.id=Eform.id);
         Eitems.add(Eitem);
      }
      insert Eform;
      }
    {
     PageReference EformPage = new ApexPages.StandardController(Eform).view();
            EformPage.setRedirect(TRUE);
   }
}

 

 

 

I have built a wizard, it goes through various steps and creates 3 records across 3 objects all linked.

 

I now want to create more than one type of record on the same object and again link, but when I do only one record is created.

 

Is there anything obvious I should be doing.

 

Thanks

 

Ross

Hi,

 

We currently have web to case enabled so clients can send us support request.

 

Had an idea to create a visualforce page within the clients org with the web to lead HTML generated code so the client can send tickets right from there system.

 

Problem is nothing happens, is this not possible I thought VF support HTML and Java.

 

Thanks

 

Ross

Hi,

 

I looking to create a mechanism to record expense.  I have created a custom object called expense form, and then another called expense item. The idea is you create an expense form (master), add expense items (child) and have the totals rolled up, finally you can submit the expenses for approval via workflow. All of this is in place and works well, but I now want to improve the user experience and I thinking of using a wizard.

 

Step 1 of the wizard would be the expense form details.

 

Step 2 the bit I need help with would be to add expense items.  I had an idea of rows with the following columns: - date, currency, type, amount. Ideally you want to have 5 or so rows on the same page that the user can quickly fill in (possibly using apex:repeat?).  If they need more then they could have a button called add row or alternatively it was save and go to another page of 5 rows.  Obviously I need all the rows to be saved as individual expense items against the form.  

 

Step 3 would be the send for approval and hit save.

 

I have built a couple of wizards but nothing like this so any thoughts, suggestions, guidance welcome.

 

Many thanks

 

Ross

 

 

 

 

Hi,

 

So have been using sf.com for a long time as an admin.  Also am a web developer using HTML, Flash and Javascript.  Tend to use Dreamweaver (DW) as our company uses CS3 products.  Started to use Eclipse to create more complex solutions using VF and APEX.

 

Want to build a site using sf.com sites.  Is there an easy was to develop in DW and upload / check-in.  Have used the force.com IDE in Eclipse which works wells.  Guess I could use the Eclipse Web Dev tools but would prefer DW.

 

I guess I am looking for and IDE or a method to easily push sites to and from DW.

 

Thanks

 

Ross

I have started to write the test script but only get 40% coverage, very new to APEX but slowly getting there with a lot of help.  Thanks to all the community for your support!

 

The code below is simple it just allows a meeting note and attendee object to sit on the same page (visualforce) and when you hit save a meeting note record is created and attendee is linked to the meeting note. 

 

I am sure the testing code is poor to say the least but I am very new to all this and having to rely on free stuff as I can't afford the developer courses yet.

 

Thanks

 

Ross

 

 

public class newMeetingController {

    public newMeetingController(ApexPages.StandardController controller) {
    }

   Meeting_Note__c meeting;
   Attendee__c attendee;
    
   public Meeting_Note__c getMeeting() {
      if(Meeting == null) Meeting = new Meeting_Note__c();
      return Meeting;
   }

   public Attendee__c getAttendee() {
      if(Attendee == null) Attendee = new Attendee__c();
      return Attendee;
   } 
    
    public PageReference cancel() {
            PageReference MeetPage = new ApexPages.StandardController(Meeting).view();
            MeetPage.setRedirect(true);
            return MeetPage; 
    }
    
   public PageReference save() {

      insert meeting; 
    
      attendee.meeting_note__c = meeting.id;
      insert attendee;

      PageReference meetPage = new ApexPages.StandardController(Meeting).view();
      meetPage.setRedirect(true);

      return meetPage;
   }
   
    public static testMethod void newMeetingController() {
    Contact c = new Contact(FirstName='Test', LastName='Contact');
    insert c;
   
    Meeting_Note__c m = new Meeting_Note__c(Subject__c='Test');
    insert m;
   
    Attendee__c a = new Attendee__c(Meeting_Note__c = m.id, Contact__c = c.id);
    insert a;
   
    System.assertEquals(c.id,a.contact__c);
   
    ApexPages.StandardController sc = new ApexPages.StandardController(a);
    newMeetingController ae = new newMeetingController(sc);
    Attendee__c attTemp = ae.attendee;
    ae.attendee = null;
    ae.getAttendee();
    ae.attendee = attTemp;
    ae.save();
    
    newMeetingController me = new newMeetingController(sc);
    Meeting_Note__c meTemp = me.meeting;
    me.meeting = null;
    me.getMeeting();
    me.Meeting = meTemp;
    me.save();
}

}

 

Need to get increased code coverage.  I currently have 73%.  The lines highlight in red seem to be the problem.  I have received help to get to this point but I not sure of the code required to test the missing lines or how to get this above the required 75%.
Thanks
Ross

 

 

public class attendeeExt {
 2	 	  
 3	 1	   Attendee__c attendee;
 4	 	  
 5	 1	   public attendeeExt(ApexPages.StandardController ctlr){
 6	 	  
 7	 1	   this.attendee = (Attendee__c)ctlr.getRecord();
 8	 	   }
 9	 	  
 10	 0	   public Attendee__c getAttendee(){
 11	 0	   if(attendee == null) attendee = new Attendee__c();
 12	 0	   return attendee;
 13	 	   }
 14	 	  
 15	 1	   public PageReference Save(){
 16	 1	   try{
 17	 1	   insert attendee;
 18	 	   }
 19	 1	   catch(DmlException ex){
 20	 1	   ApexPages.addMessages(ex);
 21	 	   }
 22	 1	   PageReference pr = new PageReference('/'+attendee.Meeting_Note__c);
 23	 1	   pr.setRedirect(True);
 24	 1	   return pr;
 25	 	   }
 26	 	   public static testMethod void testattendeeExt() {
 27	 	   Contact c = new Contact(FirstName='Test', LastName='Contact');
 28	 	   insert c;
 29	 	  
 30	 	   Meeting_Note__c m = new Meeting_Note__c(Subject__c='Test');
 31	 	   insert m;
 32	 	  
 33	 	   Attendee__c a = new Attendee__c(Meeting_Note__c = m.id, Contact__c = c.id);
 34	 	   insert a;
 35	 	  
 36	 	   System.assertEquals(c.id,a.contact__c);
 37	 	  
 38	 	   ApexPages.StandardController sc = new ApexPages.StandardController(a);
 39	 	   attendeeext ae = new attendeeext(sc);
 40	 	   ae.save();
 41	 	   }
 42	 	  }

 

 

Hi,

 

Am still a newbie on APEX and testing scripts.  The APEX code itself works exactly right.  The Testing script contained is successful with 0% coverage.

 

What the controller does

 

We have an object called meeting note, and an object called attendee.  Attendee appears as a related list on a new meeting note. When a user clicks new a visualforce page loads with a very simple input form.  When the user hits save they are returned back to the meeting note note the saved attendee record.

 

Any pointers / help on the test script would be much appreciated.

 

 

public class attendeeExt {

    Attendee__c attendee;

    public attendeeExt(ApexPages.StandardController ctlr){
        
        this.attendee = (Attendee__c)ctlr.getRecord();
    }   
    
    public Attendee__c getAttendee(){
        if(attendee == null) attendee = new Attendee__c();
        return attendee;
    }    

    public PageReference Save(){
        try{
            insert attendee;
        }
        catch(DmlException ex){
            ApexPages.addMessages(ex);
        } 
        PageReference pr = new PageReference('/'+attendee.Meeting_Note__c);
        pr.setRedirect(True);
            return pr;
    }
    public static testMethod void testattendeeExt() {        
        Contact c = new Contact(FirstName='Test', LastName='Contact');
        insert c;
        
        Meeting_Note__c m = new Meeting_Note__c(Subject__c='Test');
        insert m;
        
        Attendee__c a = new Attendee__c(Meeting_Note__c = m.id, Contact__c = c.id);
        insert a;
                
        System.assertEquals(c.id,a.contact__c);
    }
}

 

 

Thanks

 

Ross

 

 

Hi,

 

I have a quick question.  I have two visualforce pages which effectivley PDF the same record in two different formats.  They are activated by two buttons on the object.  The format used is based on a field.  Instead of having two buttons I just want one, which would force some logic (guessing APEX controller) to first look at the field and if it was a certain value it would choose format 1, if it was another value it would choose format 2.  Can anyone point me in the right direction.  Any code snippets or examples would be great.

Hi Simon,

 

Quick question.

 

Do you think it would be possible (I don't mean you, unless you have lots of free time :-) ) to have a trapdoor iPad application.

 

I am using my iPad more and more for salesforce.com, it's just a pain not having the brilliant trapdoor application to log-in quickly.

 

Cheers

 

R

I got a lot of help from people on this one a few months back so thanks to all.  Testing has gone well, I have made some changes and I am ready to push into live.

 

I now need to write a test script and I have no idea how to begin.  Any code snippets / pointers would be helpful. I rarely have to write APEX code but had not choice on this occasion.  Thanks again

 

 

public class Roommanager {
    public void search() {
        // Provide default values in the event that no dates are selected
        if(room.Search_Start_Date__c==null)
            room.Search_Start_Date__c=System.today().toStartOfMonth();        
        if(room.Search_End_Date__c==null)
            room.Search_End_Date__c=System.today().toStartOfMonth();    
        
        // Swap the dates if start is before end
        if(room.Search_Start_Date__c>room.Search_End_Date__c) {
            Date tempDate = room.Search_Start_Date__c;
            room.Search_Start_Date__c = room.Search_End_Date__c;
            room.Search_End_Date__c = tempDate;
        }
        
        // Remove previous search results
        rooms.clear();
        availableRooms.clear();
        
        // Find all the room allocations, add them to the list
        rooms.addAll(
            [SELECT
                Id, Name, Start_Date__c, End_Date__c, Nights__c, Room__c, Room__r.Room_No__c, Room__r.Lodge__c, Reservation__c, Reservation__r.Reservation_Contact__c
            FROM
                Room_Allocation__c r     
            WHERE (
                (Start_Date__c >= :room.Search_Start_Date__c  AND Start_Date__c <= :room.Search_End_Date__c) OR
                (End_Date__c  >= :room.Search_Start_Date__c  AND End_Date__c  <= :room.Search_End_Date__c) OR
                (Start_Date__c <= :room.Search_Start_Date__c  AND End_Date__c  >= :room.Search_End_Date__c))  
            ORDER BY
                Room__r.Lodge__c ASC,Room__r.Room_No__c ASC, Room__r.Lodge__c ASC]);
        
        // Build a list of allocated rooms
        Set<Id> allocatedRooms = new Set<Id>();
        for(Room_Allocation__c roomAlloc:rooms)
            allocatedRooms.add(roomAlloc.Room__c);
        
        // Add the rooms that are still available
        availableRooms.addAll(
            [SELECT
                Id, Name, Room_No__c, Lodge__c, Doubles__c, Singles__c, Style__c, Normal_PAX__c,
                (SELECT
                    Id, Name, Start_Date__c, End_Date__c, Room__c
                FROM
                    Room_Allocations__r)
            FROM
                Room__c
            WHERE
                Id NOT IN :allocatedRooms
            ORDER BY
                Lodge__c ASC, Room_No__c ASC]
        );
    }

    public Room_Allocation__c room;
    
    public List<Room_Allocation__c> rooms { get; set; }
    public List<Room__c> availableRooms { get; set; }
    
    // Constructor initialize memory variables
    public Roommanager(ApexPages.StandardController controller) {
        room=(Room_Allocation__c)controller.getRecord();
        rooms=new List<Room_Allocation__c>();
        availableRooms = new List<Room__c>();
        // Default search.
        search();           
    }
}

 

 

I have a custom object which has a start and an end date. I want to write some code which will search to see if any record occurs within those dates - easy.

 

But I also want some code that check to show any overlapping records. So for example if I search to see if records exists between the 1st March and the 30 March I want it to return all of the records below because they either fall within the search or overlap.

 

a. Record -  with a start date of 2 March and and end date of the 29 March

b. Record - with a start date of the 1st Feb and an end date of the 28 March

c. Record - with a start date of the 2nd March and an end date of the 28 April

d. Record - with a start date of the 1st Jan and an end date of the 30 April

 

Be great to get some help on this one as I am a bit stuck

Hi Simon,

 

Hope you are well.

 

Have a problem on a friends Mac they are using Maildrop (latest version).

 

Using Mac Office Outlook 2011 the email is going into the system with so strange characters.

 

Email extract Salesforce via Maildrop, any thoughts thanks as always

 

v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}st1\:*{behavior:url(#default#ieooui) }

FYI &#8211; now 4 pax in the Solomongroup so Simon Manuel will share the twin room with Danny. 
Can you please confirm the rooming listwith the accommodation, and also ensure that the car we have booked is bigenough for 4 clients, a guide, plus luggage (we would not want to have 3clients sitting in the back seat, so it probably needs to be a 7 seater.

I&#8217;ll let you know asap about theferry for Ben on the 22nd &#8211; it looks like he may be able totravel back to Ullapool on the 2.30pm ferry, so he would not need accomm inStornoway that night. I&#8217;ll confirm asap when I hear back from Danny rewhat time he needs dropped off at the airport that day.

 

I am sure this is a simple error,  code snippet below.

 

When I hit save the url of the apex page stays within the browser address bar.

 

Just can't see what I am doing wrong.

 

 

   public PageReference save() {
        insert slots;
        PageReference home = new PageReference('/a00/o');
        home.setRedirect(true);
        return home;
    }

 

 

Hi,

 

Have two problems.

 

1.  When the visualforce page below runs it saves in downloads with no association to excel.  I am guessing the content type is wrong but I have not found the right one.

 

2.  When I manually add the .xls extension and open in excel the name field (code highlighted in red) has some strange data.

 

Thanks

 

Ross

 

 

 

<apex:page standardController="Trip__c" cache="true" contenttype="application/vnd.ms-excel" showHeader="false">
    <h1>TRIP DETAILS</h1>
    <p></p>
    <br></br> 
    <apex:dataTable value="{!Trip__c}" var="T" id="TripTable" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!T.Name}" headerValue="Trip Code"/>
                <apex:column value="{!T.Trip_Title__c}" headerValue="Trip Title" />
                <apex:column value="{!T.Start_Date__c}" headerValue="Start Date"/>
                <apex:column value="{!T.End_Date__c}" headerValue="End Date"/>                       
    </apex:dataTable>
    <p></p>
    <br></br>
    <H1>GUIDE</H1> 
    <br></br>  
    <p></p>  
         <apex:dataTable value="{!Trip__c.Guides__r}" var="G" id="Guide" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!G.Guide__r.Name}" headerValue="Guide Name"/>
                <apex:column value="{!G.Guide__r.MobilePhone}" headerValue="Mobile"/>
                <apex:column value="{!G.Guide__r.Dietary_Requirements__c}" headerValue="Diet"/>
                <apex:column value="{!G.Guide__r.Medical_Conditions__c}" headerValue="Medical"/>                                     
        </apex:dataTable>
    <p></p>
    <br></br>    
    <H1>VEHICLES</H1>
    <br></br> 
    <p></p>     
        <apex:dataTable value="{!Trip__c}" var="O" id="Vehicles" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!O.Vehicles__c}" headerValue="Vechicles"/>  
        </apex:dataTable>
    <p></p>
    <br></br> 
    <H1>BOOKING DETAILS</H1>
    <br></br> 
    <p></p>   
    <apex:dataTable value="{!Trip__c.Travellers__r}" var="B" id="BookingTable" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!B.Traveller__r.Name}" headerValue="Traveller"/>
                <apex:column value="{!B.Traveller__r.Birthdate}" headerValue="DOB"/>                
                <apex:column value="{!B.Traveller__r.Total_Number_of_Trips__c}" headerValue="Number of Trips"/>
                <apex:column value="{!B.Traveller__r.Dietary_Requirements__c}" headerValue="Diet"/>
                <apex:column value="{!B.Traveller__r.Medical_Conditions__c}" headerValue="Medical"/>
                <apex:column value="{!B.Traveller__r.Chest_Size__c}" headerValue="Chest"/>
                <apex:column value="{!B.Traveller__r.Hand__c}" headerValue="Hand"/>
                <apex:column value="{!B.Traveller__r.Height__c}" headerValue="Height"/>
                <apex:column value="{!B.Traveller__r.MobilePhone}" headerValue="Mobile"/>
                <apex:column value="{!B.Traveller__r.Emergency_Contact__c}" headerValue="Emergency Contact"/>
                <apex:column value="{!B.Traveller__r.Emergency_Number__c}" headerValue="Emergency Number"/>
                <apex:column value="{!B.Cancelled_Formula__c}" headerValue="Cancelled"/>                
    </apex:dataTable>
    <p></p>
    <br></br>
    <H1>TRAVELLER NOTES</H1>
    <br></br>   
    <p></p>  
         <apex:dataTable value="{!Trip__c.Travellers__r}" var="TN" id="TripNote" headerClass="tablehead" columnClasses="tabledata">
                <apex:column value="{!TN.Traveller__r.Name}" headerValue="Traveller"/>
                <apex:column value="{!TN.Traveller__r.MailingCountry}" headerValue="Country of Residence"/>            
                <apex:column value="{!TN.Equipment__c}" headerValue="Equipment"/>
                <apex:column value="{!TN.Traveller_Notes__c}" headerValue="Notes"/>                                                     
        </apex:dataTable>
    <p></p>
    <br></br>
    <H1>ACCOMMODATION DETAILS</H1>  
    <br></br> 
    <p></p>  
    <apex:dataTable value="{!Trip__c.Rooms__r}" var="R" id="RoomTable" headerClass="tablehead" columnClasses="tabledata">   
                <apex:column value="{!R.Accommodation__r.Name}" headerValue="Accommodation Name"/>
                <apex:column value="{!R.Accommodation__r.Accommodation_Phone__c}" headerValue="Phone Number"/>
                <apex:column value="{!R.Accommodation__r.Start_Date__c}" headerValue="Start Date"/>
                <apex:column value="{!R.Accommodation__r.End_Date__c}" headerValue="End Date"/>
                <apex:column value="{!R.Accommodation__r.Nights__c}" headerValue="Nights"/>
                <apex:column value="{!R.Room_Type__c}" headerValue="Room Type"/>             
                <apex:column value="{!R.Occupant_1__r.Name}" headerValue="Occupant 1"/>
                <apex:column value="{!R.Occupant_2__r.Name}" headerValue="Occupant 2"/>
                <apex:column value="{!R.Occupant_3__r.Name}" headerValue="Occupant 3"/>
                <apex:column value="{!R.Occupant_4__r.Name}" headerValue="Occupant 4"/>                
                <apex:column value="{!R.Room_Note__c}" headerValue="Room Note"/>        
    </apex:dataTable>
    <p></p>
    <br></br>       
    <H1>TRIP NOTES</H1> 
    <br></br>     
        <apex:outputText value="{!Trip__c.Trip_Notes__c}"></apex:outputText>
    <p></p>
    <br></br> 
</apex:page>

 

 

Hi Simon,

 

I have a user who has just installed maildrop.

 

Using a mac with office 2011 outlook.

 

He tries to send an email into the system and gets the following error.

 

unknown.png

 

Can you please help.

 

Thanks

 

Ross