0

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);

}
2
  • Did you go to 'Public Access Settings' on the Site config and add permissions for the Site guest user to access opportunities?
    – metadaddy
    Apr 28, 2014 at 4:37
  • I am able to see the opportunities but not update them..I really find a way to update them..
    – miku
    Apr 28, 2014 at 5:06

3 Answers 3

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.

1

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.

1

You must create clone SObject:

Opportunity o = opp.clone(false,false,false,false);
o.id = opp.id;
update o;
1
  • So you are cloning the object and setting the ID back to the ID of the original object? Doesn't this still encounter a security problem when you try to do the "update o" line?
    – Jagular
    Apr 11, 2015 at 17:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .