You need to sign in to do that
Don't have an account?
New Idea Visualforce page
I'm 99% to a page with a decent layout for internal users. This is probably trivial, but for whatever reason, I can't find it. We only have one community, and it seems really stupid to force people to choose the community when they are creating an idea.
How do I 'hard code' the communityid in the VF page.
Here is my code that works, if I search and then select, my one community:
<apex:page standardController="idea">
<apex:form >
<apex:pageBlock title="New Idea">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Idea Details" columns="1">
<apex:inputField style="width:250px" value="{!idea.title}"/>
<apex:inputField required="true" value="{!idea.CommunityId}"/>
<apex:inputField required="true" value="{!idea.category}"/>
<apex:inputField required="true" value="{!idea.Requested_Priority__c}"/> <apex:inputField required="true" style="width:600px" value="{!idea.Business_Case__c}"/>
<apex:inputField required="true" style="width:600px" value="{!idea.body}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I've tried various tags, but there should be some way to just say that {!idea.communityid} = <id>
Also, I hope the answer isn't that I have to write a controller extension JUST to hard code this value...
Figured it out... at least using a controller...
Changed my controller to:
public with sharing class ideaExtension {
Private final Idea idea;
public ideaExtension(ApexPages.StandardController stdController) {
this.idea = (Idea)stdController.getRecord();
}
public String getCommunityId() {
return idea.CommunityId ='09a6000000003Nf';
}
}
All Answers
Thanks Ron. That's exactly what I was hoping to do... unfortunately, that didn't work.
Tried first:
<apex:variable var="{!idea.CommunityId}" value="09a6000000003Nf"/>
But it said that var had to be a literal... so I thought maybe I have to turn it around...
<apex:variable var="09a6000000003Nf" value="{!idea.CommunityId}"/>
Is what I have now, but that still doesn't work. No obvious error on the page, but the message in the system log is that communityID is a required field that's missing.
Am I doing it wrong, or is there just no way to do this without a controller extension?
I decided to go ahead and try creating a VERY simple extension to set the CommunityId variable... but I still can't figure out how to assign that to the idea.communityId variable in the form.
Here's my controller:
public with sharing class ideaExtension {
Private final Idea idea;
public ideaExtension(ApexPages.StandardController stdController) {
this.idea = (Idea)stdController.getRecord();
}
public String getCommunityId() {
return '09a6000000003Nf';
}
}
I tried a couple ways to set it, here's the last one:
<apex:variable var="CommunityId" value="{!CommunityId}" />
Any help would be appreciated...
Figured it out... at least using a controller...
Changed my controller to:
public with sharing class ideaExtension {
Private final Idea idea;
public ideaExtension(ApexPages.StandardController stdController) {
this.idea = (Idea)stdController.getRecord();
}
public String getCommunityId() {
return idea.CommunityId ='09a6000000003Nf';
}
}
Barry,
Can you clarify, why you want to add a static value to a input field.
Anyways , didn't you ever tried java script
<script>
document.getElementById('page1:form1:pb1:pbs1:fieldname').value = 'test';
</script>
or try the following link
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=863
I was able to get this done with something like this in the controller constructor (save button upserts object later):
This code allows me to create a managed package and later add community names to search for when installing into different orgs. But I'm stuck on the apex:vote component! Have you been able to permit voting in your custom page(s) without receiving the following error when one clicks on Promote or Demote?:
Field $StandardLabel.voteButton.promoted does not exist. Check spelling.
My page has this simple code with idea being a valid Idea id:
I've been stuck so I thought I'd try someone with experience in this particular "exposed wire" zone in Force.com.
Thanks for any suggestions!!
Adam Purkiss
Adam,
You might try this instead, since you're using 'idea'...:
<apex:vote id="thevote" objectId="{!idea.id}"/>
Thanks PSteve91. It's actually the same thing. I just was unclear that the IdeaId is an Idea.Id passed into my Component. But I did find a solution elsewhere on the boards and it was to include a rerender="someBlock" to the apex:vote component. The working code now looks like the following:
Cheers,
Adam
Can you please share the code for VF page and Class that you used for this. I am new to this development and am npt sure how to make this?
Thanks.
Richa