• Tate Price
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
I have a custom VF page with a custom controller in which a User can see reservations that other User have made for specific offices. 
I cannot, however, get the Reservation.createdby.Name to populate in my VF page as I do not know how to create the proper SOQL query. 

Here is my controller code:
 
wrapperDesk objwrapperDesk;
        List<Desk__c> lstDesk = [select id, Name, Desk_Number__c, createdby.Name, (select id, createdby.Name, Start_Date__c, End_Date__c from Reservations__r) from Desk__c where Office__c =: objDesk.Office__c order by Desk_Number__c asc];
        for(Desk__c dsk: lstDesk){
            objwrapperDesk = new wrapperDesk();
            objwrapperDesk.strDeskNumber = dsk.Desk_Number__c;
            objwrapperDesk.objDesk = dsk;
            map<String, Boolean> mapAvailableTemp = new map<String, Boolean>();
            for(Reservation__c rv: dsk.Reservations__r){
                
                for(integer i = 0; i <= rv.Start_Date__c.daysBetween(rv.End_Date__c);i++){               
                    mapAvailableTemp.Put(String.valueOf(rv.Start_Date__c.adddays(i).month() + '/' + rv.Start_Date__c.adddays(i).day() + '/' + rv.Start_Date__c.adddays(i).year()) + dsk.id, true);
                }
            }
            system.debug('#################'+mapAvailableTemp);
            objwrapperDesk.mapAvailable = mapAvailableTemp;
            objwrapperDesk.intMapSize = mapAvailableTemp.size();
            lstwrapperDesk.add(objwrapperDesk);

Here is the place in the VF page:
<apex:repeat value="{!lstwrapperDateRange}" var="dr">
                              
                                <apex:variable value="{!dr.objDate}{!dsk.objDesk.id}" var="mapKey"/>                                        
                                    
                                    <apex:variable value="{!1}" var="rowNum"/>  
                                    <apex:repeat value="{!dsk.mapAvailable}" var="mapAvail">                                        
                                        <apex:outputPanel rendered="{!mapAvail == mapKey}">
                                            <apex:variable var="rowNum" value="{!rowNum + 1}"/>                                                                                                                             
                                            <td class="myTabletd" bgcolor="{!If(mapAvail == mapKey,'#47BBFF', '')}">
                                                <apex:outputLabel value="{!dsk.objDesk.createdBy.Name}"></apex:outputLabel>
                                            </td>       
                                        </apex:outputPanel>                                                                       
                                    </apex:repeat>

This is the line I need changed but I cannot figure out how:
<apex:outputLabel value="{!dsk.objDesk.createdBy.Name}"></apex:outputLabel>
This needs to be the RESERVATION creator not the DESK creator. 

Please help!
 
Hi, 

I am attempting to query parent records from a custom VF page within a child record. I have Desks as a parent record of Reservations with the following values:

Desks
Office - Picklist
Desks - Dependent Picklist
Status - Picklist

Reservations
Desk - parent look-up
Start Date
End Date

My VF page contains a search area for querying reservations that match my input criteria. However, I cannot seem to pull in the picklist options from my Desks object as part of my search. 

Here is the code from my VF page:
 
<apex:page standardController="Reservation__c"  extensions="Resmanager">
    <apex:form >
        <apex:sectionHeader title="Availability Search"/>            
            <apex:pageBlock title="Search">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!reservation}" value="Search"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!Reservation__c.Start_Date__c}"/>
                    <apex:inputField value="{!Reservation__c.End_Date__c}"/> 
                    
                </apex:pageBlockSection>
            </apex:pageBlock>  
            <apex:pageBlock title="Reservations">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Office_Desk__c}"  />
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        
                        
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock> 
    </apex:form>
</apex:page>

Here is my controller:
 
Public class Resmanager {

    public PageReference reservation() {
        return null;
    }

    public Reservation__c reservation {get;set;}
    public Resmanager(ApexPages.StandardController controller) {
           reservation=(Reservation__c)controller.getRecord();
             }
            
    public List<Reservation__c> getReservations(){
            List<Reservation__c> listBd=[select Id, Name, Start_Date__c, End_Date__c, Office_Desk__c from Reservation__c r 
                where  (Start_Date__c >= :reservation.Start_Date__c 
                    and 
                    Start_Date__c <= :reservation.End_Date__c
                    )
                    or
                    (End_Date__c >= :reservation.Start_Date__c
                    and
                    End_Date__c <= :reservation.End_Date__c)];  
            return listBd;   
        }
For the SOQL loop, I only want to return the desks that 
a) are reserved
b) reserved within the specified date ranges
c) match the office the User is going to search

How do I structure the query within the VF page (for searching) and how do I construct a SOQL query to extract the matching records? 
This is my second day inside of Apex and my knowledge of SOQL is limited. 

Any assistance would be greatly appreciated as I have been searching without any luck. 
How do I use Visualforce to create custom picklist values?I am brand new to Visualforce and Apex and I need a way to find values for a specific parent object which fit a certain criteria. 

I am creating a reservation system for a remote office CRM in which users will login, look at one of two offices and find available desks. I also want the User to see which Users have reserved which desks. I know this is not possible given the picklist functionality inside of Salesforce but I am curious if it is possible using a custom VF page. 

I have three objects - Users(standard), Desk Assignments(custom) and Offices(custom). Offices have all of the physical info for the office. Desk assignments have all of the information about the reservation (Dates, Desk numbers, etc). 

1st question: should I nest the Desk numbers field within the Offices object, the Desk Reservations object or create a third custom object called Desks?

2nd question: How do I go about creating a custom Visualforce page that when a User selects an office, they see only the Available desks for the dates they wish to reserve the desk? 

I imagine the functioality to look a lot like an airplane seat reservation system in which the User can see who has reserved which desk (which I need to incorporate) and then select the desk for the specified period.

As mentioned, I am brand new to VF and Apex as my background is in Ruby. 

Thanks for any and all assistance. 
I have a custom VF page with a custom controller in which a User can see reservations that other User have made for specific offices. 
I cannot, however, get the Reservation.createdby.Name to populate in my VF page as I do not know how to create the proper SOQL query. 

Here is my controller code:
 
wrapperDesk objwrapperDesk;
        List<Desk__c> lstDesk = [select id, Name, Desk_Number__c, createdby.Name, (select id, createdby.Name, Start_Date__c, End_Date__c from Reservations__r) from Desk__c where Office__c =: objDesk.Office__c order by Desk_Number__c asc];
        for(Desk__c dsk: lstDesk){
            objwrapperDesk = new wrapperDesk();
            objwrapperDesk.strDeskNumber = dsk.Desk_Number__c;
            objwrapperDesk.objDesk = dsk;
            map<String, Boolean> mapAvailableTemp = new map<String, Boolean>();
            for(Reservation__c rv: dsk.Reservations__r){
                
                for(integer i = 0; i <= rv.Start_Date__c.daysBetween(rv.End_Date__c);i++){               
                    mapAvailableTemp.Put(String.valueOf(rv.Start_Date__c.adddays(i).month() + '/' + rv.Start_Date__c.adddays(i).day() + '/' + rv.Start_Date__c.adddays(i).year()) + dsk.id, true);
                }
            }
            system.debug('#################'+mapAvailableTemp);
            objwrapperDesk.mapAvailable = mapAvailableTemp;
            objwrapperDesk.intMapSize = mapAvailableTemp.size();
            lstwrapperDesk.add(objwrapperDesk);

Here is the place in the VF page:
<apex:repeat value="{!lstwrapperDateRange}" var="dr">
                              
                                <apex:variable value="{!dr.objDate}{!dsk.objDesk.id}" var="mapKey"/>                                        
                                    
                                    <apex:variable value="{!1}" var="rowNum"/>  
                                    <apex:repeat value="{!dsk.mapAvailable}" var="mapAvail">                                        
                                        <apex:outputPanel rendered="{!mapAvail == mapKey}">
                                            <apex:variable var="rowNum" value="{!rowNum + 1}"/>                                                                                                                             
                                            <td class="myTabletd" bgcolor="{!If(mapAvail == mapKey,'#47BBFF', '')}">
                                                <apex:outputLabel value="{!dsk.objDesk.createdBy.Name}"></apex:outputLabel>
                                            </td>       
                                        </apex:outputPanel>                                                                       
                                    </apex:repeat>

This is the line I need changed but I cannot figure out how:
<apex:outputLabel value="{!dsk.objDesk.createdBy.Name}"></apex:outputLabel>
This needs to be the RESERVATION creator not the DESK creator. 

Please help!
 
Hi, 

I am attempting to query parent records from a custom VF page within a child record. I have Desks as a parent record of Reservations with the following values:

Desks
Office - Picklist
Desks - Dependent Picklist
Status - Picklist

Reservations
Desk - parent look-up
Start Date
End Date

My VF page contains a search area for querying reservations that match my input criteria. However, I cannot seem to pull in the picklist options from my Desks object as part of my search. 

Here is the code from my VF page:
 
<apex:page standardController="Reservation__c"  extensions="Resmanager">
    <apex:form >
        <apex:sectionHeader title="Availability Search"/>            
            <apex:pageBlock title="Search">
                <apex:pageBlockButtons >
                    <apex:commandButton action="{!reservation}" value="Search"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection columns="2">
                    <apex:inputField value="{!Reservation__c.Start_Date__c}"/>
                    <apex:inputField value="{!Reservation__c.End_Date__c}"/> 
                    
                </apex:pageBlockSection>
            </apex:pageBlock>  
            <apex:pageBlock title="Reservations">
                <apex:pageBlockSection >
                    <apex:pageBlockTable value="{!Reservations}" var="res">
                        <apex:column value="{!res.Office_Desk__c}"  />
                        <apex:column value="{!res.Start_Date__c}"  />
                        <apex:column value="{!res.End_Date__c}"  />
                        
                        
                    </apex:pageBlockTable>
                </apex:pageBlockSection>   
            </apex:pageBlock> 
    </apex:form>
</apex:page>

Here is my controller:
 
Public class Resmanager {

    public PageReference reservation() {
        return null;
    }

    public Reservation__c reservation {get;set;}
    public Resmanager(ApexPages.StandardController controller) {
           reservation=(Reservation__c)controller.getRecord();
             }
            
    public List<Reservation__c> getReservations(){
            List<Reservation__c> listBd=[select Id, Name, Start_Date__c, End_Date__c, Office_Desk__c from Reservation__c r 
                where  (Start_Date__c >= :reservation.Start_Date__c 
                    and 
                    Start_Date__c <= :reservation.End_Date__c
                    )
                    or
                    (End_Date__c >= :reservation.Start_Date__c
                    and
                    End_Date__c <= :reservation.End_Date__c)];  
            return listBd;   
        }
For the SOQL loop, I only want to return the desks that 
a) are reserved
b) reserved within the specified date ranges
c) match the office the User is going to search

How do I structure the query within the VF page (for searching) and how do I construct a SOQL query to extract the matching records? 
This is my second day inside of Apex and my knowledge of SOQL is limited. 

Any assistance would be greatly appreciated as I have been searching without any luck.