I have recently started playing around with sites and created a basic page.
<apex:page controller="newController">
<apex:form >
<apex:pageBlock title="Welcome {!$User.FirstName}"></apex:pageBlock>
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Travel Details" >
<apex:inputField value="{!Booking.StartDateTime__c}"></apex:inputField>
<apex:inputText value="{!Booking.EndDateTime__c}"></apex:inputText>
<apex:inputField value="{!Booking.StartLocation__c}"></apex:inputField>
<apex:inputField value="{!Booking.EndLocation__c}"></apex:inputField>
</apex:pageBlockSection>
</apex:form>
These are the two fields that I display - one problem though, when a user clicks on the field the calendar fails to popup, they are just acting as a normal textbox.
I have searched on the web and checked user and field level permissions and everything seems to be fine. They are of the datatype datetime.
So does anyone know how I can get this calendar to display?
EDIT: I have made the code remedies suggested but unfortunately had no luck. The inputfield now displays the current date time next to the input box(as in salesforce) but still no calendar popup. I have also built the controller. Possibly a javascript issue?
Any help much appreciated,
Cheers
You need to define a standard controller and wrap your inputfield in a form in order to get the calendar to pop up, the code should look like this
<apex:page standardController="Booking__c">
<apex:form >
<apex:inputfield value="{!Booking__c.StartDateTime__c}"/>
<apex:inputfield value="{!Booking__c.EndDateTime__c}"/>
</apex:form>
</apex:page>
Try inputText instead:
Note: Read-only fields, and fields for certain Salesforce objects with complex automatic behavior such as Event.StartDateTime and Event.EndDateTime, don't render as editable when using <apex:inputField>. Use a different input component such as <apex:inputText> instead.
Source: apex:inputField (Salesforce.com)
I figured it out, if anyone comes across the same issue you need to activate the site.
Anyway thanks for all the responses.
Related
I have below requirement to Create a VF page.
I created a custom object called DormsApplicants__c There are several fields but for the purposes of the example we will use only one field called First_name__c.
My main need is to create a VF page that will be available to people outside the organization (i.e. customers) who can enter data into the form and then create a record in the custom object DormsApplicants__c. For this purpose I created a website (SITE.COM) and then created a VF page (called TEST) I defined this page (TEST) as a home page on the site.
This is my page:
<apex:page standardController="DormsApplicants__c" sidebar="false">
<apex:form id="theForm">
<apex:pageBlock title="TEST">
<apex:inputText title="TEXTBOX1" label="TEXTBOX2" value="{!DormsApplicants__c.First_name__c}"/>
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlock>
</apex:form>
Image A1 - This is what users see outside the organization.
When the user tries to click "save" he gets the following error:
Image B1 - error on save
Of course no record is created. I'd love to hear what the problem is?
I have a visualforce page with the standardController to a custom object.
I want to get all orders (Orders__c) from an event (Event__c). I started by the offer (Offer__c)
Offer is in master-detail with the event and the event is in master-detail with the orders.
I have tried two following codes:
<apex:page standardController="Caterer_Offer__c" sidebar="false" showHeader="false" >
<apex:repeat var="events" value="{!Caterer_Offer__c.Event__r}">
{!events.Name}
<apex:repeat var="orders" value="{!events.Orders__r}">
<!-- {!orders.Name}-->
</apex:repeat>
</apex:repeat>
At this the error-message in the developer console is:
"Aggregate Relationship is used in an unsupported complex expression containing 'Event__r.orders__r'"
And...then I have trief to save the event and use a new variable to "repeat" all orders. I get no error message, but a error in Salesforce
<apex:page standardController="Caterer_Offer__c" sidebar="false" showHeader="false" >
<apex:repeat var="events" value="{!Caterer_Offer__c.Event__r}">
{!events.Name}
<apex:variable var="e" value="{!events}"/>
<apex:repeat var="orders" value="{!e.Orders__r}">
<!-- {!orders.Name}-->
</apex:repeat>
</apex:repeat>
Error-message: SObject row was retrieved via SOQL without querying the
requested field: Event__c.Orders__r
I cannot explain it and work on it since a few hours....
A standardcontroller's record will only contain the fields referenced in the visualforce page you're using it on. You may need to use a custom controller and extend features of standard controller in these cases. The standard controller addFields() method allows you to extend this to the fields you need in your apex code.
I could find a similar solution here.
I'm not sure from your question which object is the Parent record and which is the child, but my answer is going to be based on Caterer_Offer__c being the parent of Event__c and Event__c being the parent of Order__c, so that you can loop through all Orders for an Event for a Catered Offer which is what I think you want to do.
In short what you are trying to do cannot be done in the way you are trying it is because you are in essence trying to perform a child aggregate query that is two levels deep. In essence you are trying to do:
[SELECT Name, (SELECT Name, (SELECT Name FROM Orders__r) FROM Events__r) FROM Caterer_Offer__c];
However salesforce only allows aggregate child queries one level deep, not more. So you have to add an extension that would have code to probably lazy-load the Orders on an event of some sort with a partial page re-render on a link click or button click. In that case you would make the Visualforce page for the Caterer_Offer__c and child Events__c, then load the child Orders from some user action that calls the extension with a element using the id of the selected Event.
But for the error you specifically asked about it would have been:
<apex:page standardController="Caterer_Offer__c" sidebar="false" showHeader="false" >
<apex:repeat var="event" value="{!Caterer_Offer__c.Events__r}">
{!event.Name}
<apex:repeat var="order" value="{!event.Orders__r}">
{!order.Name}
</apex:repeat>
</apex:repeat>
</apex:page>
But again that's not possible because of the aforementioned single depth child aggregation query limitation in salesforce
I am working with Apex controller and Visual Force page.
Inside of the vf page I had a data table and each row of that table binds to a value from a list that generated from the controller
example code:
<apex:dataTable value="{!List}" var="item" styleClass="class1" >
...
<apex:column headerValue="Header1">
<apex:outputpanel rendered="{!NOT((a=='true'))}">
<div class='estimate-name-column'>
<apex:inputField value="{!item.Name}" required='true' rendered="{!(a=='false')}"/>
</div>
</apex:outputpanel>
</apex:column>
...
</apex:datatable>
As you can see, I was trying to hide some inputFields base on some conditions.
However, there was a problem. If I do the above, those inputFields who get rendered were not binded correctly. After submited the form with this data table, inside my controller all the records' in list Name are null. Even though I saw the 'Name' was posted in http request.
I am guessing is render interfere with the binding? because if I remove the rerendered conditions and display all InputField I can get the values inside the controller after submitting form
any ideas what happened?
If I recall correctly an apex tag must be present on the page in order to be rerendered.
In other words - something (maybe as simple as <span id="long:generated:salesforce:id"></span>) must be in HTML in order for later AJAX updates to inject new content into the placeholder. If it's not rendered, it will stay not rendered.(1)
Instead of rendered try to move your condition to styleor styleclass attributes. Something like
<apex:inputField value="{!item.Name}"
required="{!a=='false'}"
style="display:{!IF(a=='false','inline', 'none')}"/>
visibility:hidden (if you want them to occupy their space but not be seen) or display:none (to have them appear to be completely not there. See also What is the difference between visibility:hidden and display:none?
Footnote:
(1) unless of course you'll rerender a tag that contains "this" tag (something higher in the XML).
I want to embed videos in my knowledge articles, and I have been trying to follow the steps from these two posts:
http://boards.developerforce.com/t5/General-Development/Embedded-Video-in-New-Knowledge-Base/td-p/19...
http://success.salesforce.com/ideaView?id=087300000006n6v
Under Setup->Customize->Knowledge->Article Types, I have an article type of "Video Tutorial" with the title test_video_tutorial. I have a custom field called "Tutorial" with an API name of "Tutorial__c".
In Article Management, I created a new article of type "Video Tutorial" and the Tutorial field I have this:
<div class="youtube">http://www.youtube.com/v/TDArzCNu178?</div>
In Setup->Develop->Pages, I created a new Visualforce Page called VideoTutorialPage like this:
<apex:page standardController="Video_Tutorials__kav" showHeader="true">
<apex:outputPanel >
<apex:outputField value="{!Video_Tutorials__kav.Title}"/>
<apex:outputText escape="false" value="{!Video_Tutorials__kav.Tutorial__c}"/>
</apex:outputPanel>
</apex:page>
However, when I click on the article "test_video_tutorial" in my Articles, the video doesn't get embedded. I just see the html code for it. Is there something I have to do to tell Salesforce that when I click on a Video Tutorial article, that it should use the Visualforce Page I created? What is it that I have to do to get the video to show up?
In the Summer 12 release this was made a lot easier by allowing <iframe> tags in knowledge articles. See the Summer 12 release notes (section "Multimedia Content in Articles") for details
How to hide a section of fields using a checkbox in visualforce pages?
Assuming the Salesforce approach (keeping the page weight down etc.), you could do something like the following:
<apex:inputCheckbox value="{!theBool}">
<apex:actionSupport event="onChange" action="{!myAction}" rerender="theFieldsPanel"/>
</apex>
<apex:outputPanel id="theFieldsPanel">
<apex:variable var="v" value="" rendered="{!theBool}">
<apex:inputField value="{!someField"} rendered/>
<!-- more fields etc. -->
</apex:variable>
</apex:outputPanel>
Note that I don't use the rendered attribute on the output panel itself, this is because if it's not rendered then it doesn't exist in the page, and as such, doesn't make for a good rerender target! Now you just require a simple action on the controller (you could do any other logic in here if need be):
public Pagereference myAction()
{
// any logic etc. goes here
return null;
}
The benefit of doing things this way, as opposed to with javascript is that you can ensure that if the fields are hidden then values won't be sent back to the controller for the variables they're bound to. Simply hiding things with javascript would not have the same effect, so say the user typed something in one of the fields and then hid them, whatever he/she typed would still end up in the related controller variables.