function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MVJMVJ 

IELD_INTEGRITY_EXCEPTION, No selected contact

I have a visual force page that was created in Summer 10 in my FCS to update cases.

 

The page allowed the user to change the case status and also create an entry into a customer object and create a case comment all from the same page.

 

It was working perfect in until today.  the only change was my Sandbox was updated to Spring 10.

 

Now whenever I try to update the case from the Visual Force Page I get the following error:

 

System.DmlException: Update failed. First exception on row 0 with id 50030000005o8ETAAY; first error: FIELD_INTEGRITY_EXCEPTION, No selected contact: [ContactId]

 

If I edit the case from GUI I do not get the error.  If I select a contact (Which is not a required field) and then execute the visual force page ot works fine.

 

What has chnaged in Spring 10 that is causing this to happen.

 

Any help is apprciated.

 

 

Here is the page:

 

 

<apex:page Controller="newEnhancemnetController" tabStyle="Case" id="thePage"> <script> function confirmCancel() { var isCancel = confirm("Are you sure you wish to cancel?"); if (isCancel) return true; return false; } </script> <apex:sectionHeader title="New Enhancemnet Approval" subtitle="for change board Case"/> <apex:form > <apex:pageBlock mode="edit"> <apex:pageMessages ></apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton action="{!Save}" value="Save"/> <apex:commandButton action="{!Cancel}" value="Cancel" onclick="return confirmCancel()" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Change Current Case Status" columns="1"> <apex:outputField value="{!Case.id}"/> <apex:outputField value="{!Case.subject}"/> <apex:outputField value="{!Case.description}"/> <apex:pageBlockSectionItem > <apex:outputLabel value="{!$ObjectType.Case.fields.Status.label}" for="casestatus" style="font-weight:bold"/> <apex:outputPanel styleClass="requiredInput" layout="block"> <apex:outputPanel styleClass="requiredBlock" layout="block"/> <apex:selectList value="{!casestatus}" id="casestatus" size="1" title="Status" required="true"> <apex:selectOptions value="{!items}"/> </apex:selectList> </apex:outputPanel> </apex:pageBlockSectionItem> </apex:pageBlockSection> <apex:pageBlockSection title="Add Enhancement Approval Information" columns="2"> <apex:inputField id="eaAprovedFor" value="{!EnhancementApproval.Approved_For__c}" required="true"/> <apex:inputField id="eaEnvironment" value="{!EnhancementApproval.Environment__c}" required="true"/> <apex:inputField id="eaValidFrom" value="{!EnhancementApproval.Valid_From__c}" required="true"/> <apex:inputField id="eaOtherQCS" value="{!EnhancementApproval.Other_QCS__c}" required="False"/> <apex:inputField id="eaValidTo" value="{!EnhancementApproval.Valid_To__c}" required="true"/> </apex:pageBlockSection> <apex:pageBlockSection title="Add a Case Comment"> <apex:inputField id="caseComment" value="{!CaseComment.CommentBody}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>

 

 Here is the controller:

 

 

public class newEnhancemnetController { String casestatus; Case oCase; Enhancement_Approval__c oEnahncemnetApproval; Contact contact; CaseComment casecomment; Map<String,String> mCaseStatus = new Map<String,String>(); public Case getCase() { oCase = [select id, subject, status, description from Case where id = :ApexPages.currentPage().getParameters().get('id')]; if(oCase== null) oCase= new Case(); return oCase; } public Contact getContact() { if(contact== null) contact= new Contact(); return contact; } public String getCaseStatus() { if(casestatus==null){casestatus=oCase.Status;} return casestatus ; } public void setCaseStatus(String casestatus ) { this.casestatus = casestatus ; } public List<SelectOption> getItems() { mCaseStatus.Put('New','New'); mCaseStatus.Put('Approved for Analysis & Design','Approved for Analysis & Design'); mCaseStatus.Put('Reqmts/A&D In Progress','Reqmts/A&D In Progress'); mCaseStatus.Put('Reqmts/A&D Completed','Reqmts/A&D Completed'); mCaseStatus.Put('Approved for Sandbox Build/Config/Test','Approved for Sandbox Build/Config/Test'); mCaseStatus.Put('Sandbox Build In Progress','Sandbox Build In Progress'); mCaseStatus.Put('Sandbox Testing Failed','Sandbox Testing Failed'); mCaseStatus.Put('Sandbox Testing Passed','Sandbox Testing Passed'); mCaseStatus.Put('Waiting for Production Release Date','Waiting for Production Release Date'); mCaseStatus.Put('Release Date Assigned/Approved for Prod','Release Date Assigned/Approved for Prod'); mCaseStatus.Put('Production Testing Failed','Production Testing Failed'); mCaseStatus.Put('Production Testing Passed','Production Testing Passed'); mCaseStatus.Put('On Hold / No Activity','On Hold / No Activity'); mCaseStatus.Put('On Hold / Lack of Funding','On Hold / Lack of Funding'); //mCaseStatus.Put('',''); List<SelectOption> options = new List<SelectOption>(); Schema.DescribeFieldResult fieldResult = Schema.sObjectType.Case.Fields.Status; fieldResult = fieldResult.getSObjectField().getDescribe(); List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues(); for( Schema.PicklistEntry f : ple) { if (mCaseStatus.containskey(f.getValue())) options.add(new SelectOption(f.getLabel(), f.getValue())); //options.add(new SelectOption(f.getLabel(), f.getValue())); } return options; } //public List<SelectOption> getItems() { // List<SelectOption> options = new List<SelectOption>(); // for (CaseStatus cs : [Select MasterLabel from CaseStatus order by sortorder]){ // options.add(new SelectOption(cs.MasterLabel,cs.MasterLabel)); // } // return options; //} public CaseComment getCaseComment () { if(casecomment== null) casecomment= new CaseComment(); return casecomment; } public Enhancement_Approval__c getEnhancementApproval() { if(oEnahncemnetApproval== null) oEnahncemnetApproval= new Enhancement_Approval__c(); return oEnahncemnetApproval; } public PageReference cancel() { PageReference casePage = new ApexPages.StandardController(oCase).view(); casePage .setRedirect(true); return casePage ; } public PageReference Save() { if (oEnahncemnetApproval.Environment__c == 'QCS - Other' && oEnahncemnetApproval.Other_QCS__c ==Null ){ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Other QCS is Required when Environment is equal to "QCS - Other"'); ApexPages.addMessage(myMsg); return null; } oCase.Status=this.casestatus; update oCase; Enhancement_Approval__c oEA; oEA = new Enhancement_Approval__c(); oEA.Approved_For__c = oEnahncemnetApproval.Approved_For__c; oEA.Case__c = ApexPages.currentPage().getParameters().get('id'); oEA.Environment__c = oEnahncemnetApproval.Environment__c; oEA.Valid_From__c = oEnahncemnetApproval.Valid_From__c; oEA.Valid_To__c = oEnahncemnetApproval.Valid_To__c; oEA.Other_QCS__c = oEnahncemnetApproval.Other_QCS__c; insert oEA; if (casecomment.CommentBody != null){ casecomment.ParentId = ApexPages.currentPage().getParameters().get('id'); insert casecomment; } PageReference casePage = new ApexPages.StandardController(oCase).view(); casePage.setRedirect(true); return casePage ; } //*************************************************************************** //** Test Method //** //*************************************************************************** public static testMethod void testChangeBoardApproval() { pageReference p = Page.ChangeBoardApproval; p.getParameters().put('id', [select id from Case limit 1].id); test.setCurrentPage(p); newEnhancemnetController enhancmenetController = new newEnhancemnetController(); //enhancemnetController.cancel(); enhancmenetController.getCase(); enhancmenetController.getitems(); enhancmenetController.getcasestatus(); enhancmenetController.getEnhancementApproval(); enhancmenetController.getContact(); enhancmenetController.getCaseComment(); enhancmenetController.save(); } }

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
MVJMVJ

All,  I got a note from Support that this was corrected.  I tested it this morning and it seems to be working now.

 

 

All Answers

JconsultantJconsultant
I'm getting the exact same error and the only change was Spring '10 was pushed to my sandboxes.  It looks like it's going to be pushed to Production on Feb 6th.  I hope we can resolve this before then.  If not, I'm going to have to definitely come up with some sort of workaround.
gtuerkgtuerk

We have 7 Unit Tests failing, as of this morning, based on the new Spring '10 functionality.  Hoping for a moderator message on this one...

jwolfjwolf
I have a managed package that is now getting the same error when going to create a case in any sandbox that has the spring 10 release in it. Any ideas?
CapWCapW

I've had the exact same issue that you all have had so far.  I managed to find a temporary solution that at least works for me, but may not work for everyone. 

 

What I've done is to associate dummy contact with the Case and within that contact, the Email filed must be filled in.

 

So what I've done to "duct tape" a fix is this:

 

 

Contact con = [select id from Contact where Name = 'Test' limit 1]; currCase.ContactId = con.Id; con.Email = 'test@test.tst'; update con; update currCase;

 This assumes that you have a contact named 'Test' created.

 

Apparently, for some reason, the email field for the contact is 'required' now.  Hopefully, this will help you get your code 'temporarily' working until salesforce implements a fix.

 

Cheers,

 

W

 

JconsultantJconsultant
Thanks Cap.  I will end up doing something like that if I have to, but I currently have a case open with Premier Support and they are calling it an "unexpected behavior".  It is being escalated and is being worked on.  Hopefully this will be fixed prior to the production rollout on Feb 6.
CapWCapW

Yeah, I hope so too.  Took me way too long to debug this problem :-) .  And it is a really ugly fix.

 

Cheers,

 

-W

DaveGraupnerDaveGraupner

Just checking if anyone has an update on this. I just starting seeing this problem in the sandbox as well, with code that was working a week ago.

 

Thanks

 

Dave

gtuerkgtuerk
I'm eagerly anticipating moderator response.  I'm not changing my unit tests to expect a contact on any case... (as the workaround above calls out)
MVJMVJ
I have recived an update form SFDC.  All that they are saying right now is that this a release bug and they are working on correcting it.  They have not provided an ETA.  If I hear anything new I will update the post.
jwetzlerjwetzler
This wasn't a Visualforce bug so I'm not very familiar with it, but I believe this was fixed last night.  Can someone confirm?
JconsultantJconsultant

Jill,

 

I have an open case with Tier 2 dev support right now addressing this issue.  The missing ContactId bug appears to be fixed but there is still a bug that is related.  If you update a case on the backend via apex and the contact related to the case does not have an email or has an invalid email address on it there is an exception thrown saying that the email field is required.  It is not required.  My case is still open and they are looking into this side issue.

DaveGraupnerDaveGraupner

The missing ContactId bug is still there when I tried running my tests just now.

 

Dave

MVJMVJ

All,  I got a note from Support that this was corrected.  I tested it this morning and it seems to be working now.

 

 

This was selected as the best answer
Scott.MScott.M

This little gem looks like it's back. Since the Winter 12 Update I've been seeing this error in my dev orgs.

 

Can anyone confirm this to be true?

 

Thanks

RARA

I tried the repro steps detailed in the first post and did not see the same issue.

Please open a support case. This is likely some completely different issue that happens to result in the same error message.