I want to show opportunity fields on Force.com and also update an opportunity from force.com sites..
When i am using apex:input fields the fields are not showing in input mode.When i use inputtext it works.My problem is about date fields it comes as a inputtext and dateselector doesn't come.
Now i also want to update the opportunity record.I have found that we can't update standard object.I have found one link where it says if you use without sharing then you can update. Workarounds for Sites page to update standard object?
But i am not able to do it.Please help in this.Its really very urgent for me.
VF page
<apex:page controller="oppDetailUsersCntlr" showHeader="false" cache="false" >
<apex:form >
<apex:sectionHeader title="Opportunity" subtitle="Detail"/>
<apex:pageBlock mode="inlineEdit" rendered="{!editSection}">
<apex:pageBlockButtons >
<apex:commandButton value="Save" id="saveButton" action="{!saveOpp}"/>
<apex:commandButton value="Edit" id="editButton" action="{!editOpp}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2">
<apex:inputText value="{!opp.name}"/>
<apex:inputField value="{!opp.closedate}"/>
<apex:outputField value="{!opp.accountid}"/>
<apex:inputText value="{!opp.Probability}"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:page>
Controller
public void saveOpp()
{
editSection=false;
saveSection=true;
Opportunity o=new opportunity(id=id);
o.Probability=opp.Probability;
update o;
System.debug('==============oooooooo============'+o);
}
Attribution to: miku
Possible Suggestion/Solution #1
It appears you may not have fully understood what was being conveyed in the post you've cited in your post. A Sites user license does not allow access to standard objects. The post you're referring to was speaking of using a "mirror" object and a trigger to update Opportunity via sites. That page was also discussing the different types of sharing models to use on the controller and what that meant in terms of user permissions.
Without the proper licenses, your Sites users will not be able to make updates directly to the Opportunity object. You'll need to set up a partner portal/community if you want to be able update Opportunity without using a mirrored object and triggers to do it indirectly.
Attribution to: crmprogdev
Possible Suggestion/Solution #2
There is a workaround. Use empty variable inputs in place of any apex:inputFields, then in your controller's update method, assign those values to the standard object fields and update the object. The key is to do any manipulation of the standard object in the controller instead of directly accessing it on the VF page because the controller will run with system admin profile settings.
To give the appearance of an apex:inputField, query your standard objects on the VF page using remote objects. You can then prepopulate your empty variable inputs using javascript or whatever you'd prefer.
Attribution to: Z_wizard18
Possible Suggestion/Solution #3
You must create clone SObject:
Opportunity o = opp.clone(false,false,false,false);
o.id = opp.id;
update o;
Attribution to: Den
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33796