• Apple88
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies

Hi,

 

Sorry for the message I sent before displayed in a mess.  Hope this one looks better.  Below is the case:

 

When two users use the standard Edit page to edit the same record of a custom object at the same time, Force.com does control the concurrent update properly and display the error message as below when the second user tries to save his changes:

 

 

Your Changes Cannot Be Saved

The record you were editing was modified by Apple88 during your edit session.

Please re-display the record before editing again.

 

However, when I built a custom Visualforce page and override the standard Edit button of the custom object with the custom page, the custom page failed to manage the concurrent update properly.  Both users are able to retrieve and edit the same record at the same time, and able to save their changes successfully.  As the result, the changes made by the second user overwrite the changes of the first user without knowing.

 

Below is my custom page:

 

<apex:page standardController="Customer__c" extensions="CustomerEditCX"> <apex:variable var="CS" value="{!Customer__c}"/> <apex:sectionHeader title="Customer Edit" subtitle="{!CS.Name}"/> <apex:form > <apex:pageMessages ></apex:pageMessages> <apex:pageBlock mode="edit"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockSection > <apex:inputField value="{!CS.Name}" required="true"/> <apex:outputField value="{!CS.Status__c}"/> <apex:inputField value="{!CS.Number__c}"/> <apex:inputField value="{!CS.Owner__c}" required="true"/> </apex:pageBlockSection> <apex:pageBlockSection title="Contact Details"> <apex:inputField value="{!CS.Contact_Person__c}"/> <apex:inputField value="{!CS.Contact_Phone__c}"/> <apex:inputField value="{!CS.Fax_Number__c}"/> <apex:inputField value="{!CS.Mobile_Phone__c}"/> <apex:inputField value="{!CS.Corresponding_Address__c}"/> <apex:inputField value="{!CS.Email_Address__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

The above custom page use standard controller.  Not quite understand why it behaves differently from the standard Edit page? 

 

I have also tried to add a SOQL with "for update" option in the controller extension to lock the record.  However, it still failed to control the concurrency update properly.  Below is the controller extension:

 

public with sharing Class CustomerEditCX { Customer__c CS = new Customer__c(); public CustomerEditCX(ApexPages.StandardController StdController) { CS = (Customer__c)Stdcontroller.getRecord(); if (CS.ID != Null) { CS = [select Owner__c, Status__c from Customer__c where ID = :CS.ID for update]; system.debug('Supposed lock successfully: ' + CS.ID); } if (CS.Status__c == Null) { CS.Status__c = 'Draft'; } } }

 

Would anyone let me why the "for update" option does not work in the controller extension and how could we fix the problem?

 

Thanks for your help in advance.

 

Apple88

Hi,

 When two users use the standard Edit page to edit the same record of a custom object at the same time, Force.com does control the concurrent update properly and display the error message as below when the second user tries to save his changes: 
Your Changes Cannot Be Saved
The record you were editing was modified by Apple88 during your edit session.

Please re-display the record before editing again.
However, when I built a custom Visualforce page and override the standard Edit button of the custom object with the custom page, the custom page failed to manage the concurrent update properly.  Both users are able to retrieve and edit the same record at the same time, and able to save their changes successfully.  As the result, the changes made by the second user overwrite the changes of the first user without knowing. Below is my custom page: <apex:page standardController="Customer__c" extensions="CustomerEditCX"><apex:variable var="CS" value="{!Customer__c}"/><apex:sectionHeader title="Customer Edit" subtitle="{!CS.Name}"/><apex:form ><apex:pageMessages ></apex:pageMessages><apex:pageBlock mode="edit"><apex:pageBlockButtons ><apex:commandButton value="Save" action="{!save}"/><apex:commandButton value="Cancel" action="{!cancel}"/></apex:pageBlockButtons><apex:pageBlockSection ><apex:inputField value="{!CS.Name}" required="true"/><apex:outputField value="{!CS.Status__c}"/><apex:inputField value="{!CS.Number__c}"/><apex:inputField value="{!CS.Owner__c}" required="true"/></apex:pageBlockSection><apex:pageBlockSection title="Contact Details"><apex:inputField value="{!CS.Contact_Person__c}"/><apex:inputField value="{!CS.Contact_Phone__c}"/><apex:inputField value="{!CS.Fax_Number__c}"/><apex:inputField value="{!CS.Mobile_Phone__c}"/><apex:inputField value="{!CS.Corresponding_Address__c}"/><apex:inputField value="{!CS.Email_Address__c}"/></apex:pageBlockSection></apex:pageBlock></apex:form></apex:page> I have also tried to add a SOQL with “for update” option in the controller extension to lock the record.  However, it still failed to control the concurrency update properly.  Below is the controller extension: public with sharing Class CustomerEditCX {    Customer__c CS = new Customer__c();    public CustomerEditCX(ApexPages.StandardController StdController) {        CS = (Customer__c)Stdcontroller.getRecord();        if (CS.ID != Null) {            CS = [select Owner__c, Status__c from Customer__c                  where ID = :CS.ID for update];            system.debug('Supposed lock successfully: ' + CS.ID);             }                  if (CS.Status__c == Null) {            CS.Status__c = 'Draft';        }          }} Would anyone let me know how to fix this problem? Thanks for your help in advance. Apple88

I created a custom object named as "Currency__c" and set on the option of track field history for this object. Then I want to build a detail page for this object with the related list of Currency History displayed on a separate tab.

 

According to Force.com documentation, Force.com will create an object called Currency__History object automatically when I set on the option of track field history for Currency__C object.

 

Also by checking the schema definition, I found that the child relationship name for Currency__History object is "Histories". Therefore, I put the following coding in the Visualforce page:

 

<apex:relatedList list="Histories" />

 

However, when I execute the Visualforce page, I receive the following error:

 

'Histories' is not a valid child relationship name for entity Currency

 

Would anyone pls help me and indicate what I have done incorrectly?

I created a custom object with the name 'Order'.  It is enabled to track field history.  I want to create a Visualforce page to display the track field history in a separate tab.  I know we can use the apex tag <apex:relatedList List="????" /> for this purpose.  However, could anyone advise what should be the child relationship name for the List attribute in this case.

 

Thanks for your advice in advance.

 

Best regards

Apple88

There are two objects.  Each has a picklist field called "Month".  Is there a way to set up the picklist (i.e. Jan, Feb, ..., Dec) once instead of typing the picklist repeatedly in each object?

 

Thanks for your help.

When creating a picklist to a field, Force.com add a picklist item "--None--" automatically.  In some situations, we may not want to provide the "None" option for user to select.  Is it possible to remove the "None" option from the picklist?

I created a custom object with the name 'Order'.  It is enabled to track field history.  I want to create a Visualforce page to display the track field history in a separate tab.  I know we can use the apex tag <apex:relatedList List="????" /> for this purpose.  However, could anyone advise what should be the child relationship name for the List attribute in this case.

 

Thanks for your advice in advance.

 

Best regards

Apple88

For a custom object, is there a built-in action I can specify within a command button to get a "Save & New" button?
 
<apex:commandButton value="Save" action="{!Save}"/>