• Richard101
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello

We have a custom object (QuoteOrder__c) which is the child in a master-detail relationship with Opportunity.

On my visualforce page my intention is to have it display the Contacts on the Opportunity (via OpportunityContactRole) once you have selected an opportunity from the lookup dialog. I've tried this and it works fine until you change the text in the opportunity field and click or tab out of the field (and therefore clear the underlying Opportunity Id) at which point the page reloads and just gives me the error "SObject row does not allow errors".


For simplicity, I've reduced my page down to just this:
<apex:page controller="QuoteOrder">
    <apex:form >
        <apex:pageBlock>
            <apex:pageBlockSection columns="1"> 
                <apex:inputField value="{!quoteOrder.OpportunityLink__c}" id="opportunity" label="Opportunity">
                    <apex:actionSupport event="onchange" rerender="details" />
                </apex:inputField>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection columns="1" id="details">
                <!-- Other stuff will go here when an opportunity is selected -->
                <apex:messages></apex:messages>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

And I've reduced my controller down to just this:
public with sharing class QuoteOrder {
    public QuoteOrder__c quoteOrder { get; set; }

    public QuoteOrder() {
        this.quoteOrder = (QuoteOrder__c)QuoteOrder__c.SObjectType.newSObject(null, true);
    }
}

I assume it's upset because in the master-detail relationship the opportunity is a compulsory field and the page is submitting with no value. To this end, I have used jquery to check the value of the underlying Id when the blur event is activated, and then if the Id is undefined I have used event.preventDefault() but the page still submits and presents me with the error message. Can anybody suggest how I can stop it submitting in this situation please?

Thank you
Richard
Hello

We have a custom object (QuoteOrder__c) which is the child in a master-detail relationship with Opportunity.

On my visualforce page my intention is to have it display the Contacts on the Opportunity (via OpportunityContactRole) once you have selected an opportunity from the lookup dialog. I've tried this and it works fine until you change the text in the opportunity field and click or tab out of the field (and therefore clear the underlying Opportunity Id) at which point the page reloads and just gives me the error "SObject row does not allow errors".


For simplicity, I've reduced my page down to just this:
<apex:page controller="QuoteOrder">
    <apex:form >
        <apex:pageBlock>
            <apex:pageBlockSection columns="1"> 
                <apex:inputField value="{!quoteOrder.OpportunityLink__c}" id="opportunity" label="Opportunity">
                    <apex:actionSupport event="onchange" rerender="details" />
                </apex:inputField>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection columns="1" id="details">
                <!-- Other stuff will go here when an opportunity is selected -->
                <apex:messages></apex:messages>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

And I've reduced my controller down to just this:
public with sharing class QuoteOrder {
    public QuoteOrder__c quoteOrder { get; set; }

    public QuoteOrder() {
        this.quoteOrder = (QuoteOrder__c)QuoteOrder__c.SObjectType.newSObject(null, true);
    }
}

I assume it's upset because in the master-detail relationship the opportunity is a compulsory field and the page is submitting with no value. To this end, I have used jquery to check the value of the underlying Id when the blur event is activated, and then if the Id is undefined I have used event.preventDefault() but the page still submits and presents me with the error message. Can anybody suggest how I can stop it submitting in this situation please?

Thank you
Richard