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
rfisher000rfisher000 

FIELD_CUSTOM_VALIDATION_EXCEPTION, Huh?

I'm trying to update parent/child relationships between Account objects and I am getting the following error.

 

Child Accounts cannot be "Parent" Account Record Type (Additional Information Section Below). - FIELD_CUSTOM_VALIDATION_EXCEPTION

 

Not finding a lot on this error message (in whole or in part).

Anyone have any ideas?

 

For what its worth here is a code snipet and a brief explanation.

I'm iterating thru a list of companies on my local system.

I'm querying the child account and then the parent account in SF.

If the value int he child account is wrong, I attempt to set the ParentID and update the object.

 

FileLogger.debug(",SyncParentChild"); AssignmentRuleHeader arh = new AssignmentRuleHeader(); MruHeader mruh = new MruHeader(); AllowFieldTruncationHeader afth = new AllowFieldTruncationHeader(); DebuggingHeader dh = new DebuggingHeader(); EmailHeader eh = new EmailHeader(); DebuggingInfoHolder dih = new DebuggingInfoHolder(); SaveResult[] results = new SaveResult[1]; results[0] = new SaveResult(); QueryResult qr = null; QueryOptions qo = new QueryOptions(); Account parentAccount = new Account(); Account account = new Account(); arh.setUseDefaultRule(false); dh.setDebugLevel(DebugLevel.Db); Collection companyProfiles = (Collection)session.executeQuery("findAllCompanyProfileChildren", CompanyProfile.class, "130#7"); for (Iterator itr = companyProfiles.iterator(); itr.hasNext(); ) { companyProfile = (CompanyProfile)itr.next(); FileLogger.debug(companyProfile.getCustomerEntity() + ",UpdateParentChild = " + companyProfile.getOwnerEntity()); try { checkSforceSession(); qr = sforce_port.query("SELECT Id, ParentId FROM Account WHERE Customer_ID__c = '" + companyProfile.getCustomerEntity() + "'", sh, qo, mruh, pvh); } catch (ApiQueryFault e) { ApiQueryFaultHandler(e); } catch (ApiFault e) { ApiFaultHandler(e); } account = new Account(); if (qr.getSize() == 1) { account = (Account)qr.getRecords()[0]; } else if (qr.getSize() == 0) { FileLogger.warn(companyProfile.getCustomerEntity() + ",[SF] Unable to locate this Account to establish Parent account"); } else if (qr.getSize() > 1) { FileLogger.warn(companyProfile.getCustomerEntity() + ",[SF] Located multiple Accounts with this ID when establishing Parent account"); } try { checkSforceSession(); qr = sforce_port.query("SELECT Id FROM Account WHERE Customer_ID__c = '" + companyProfile.getOwnerEntity() + "'", sh, qo, mruh, pvh); } catch (ApiQueryFault e) { ApiQueryFaultHandler(e); } catch (ApiFault e) { ApiFaultHandler(e); } parentAccount = new Account(); if (qr.getSize() == 1) { parentAccount = (Account)qr.getRecords()[0]; FileLogger.debug(companyProfile.getCustomerEntity() +",Child is " + account.getId() ); FileLogger.debug(companyProfile.getCustomerEntity() +",Child has " + account.getParentId() + " Parent is" + parentAccount.getId()); if ((parentAccount.getId() != null) && ((account.getParentId() == null) || (account.getParentId().compareTo(parentAccount.getId())) != 0)) { account.setParentId(parentAccount.getId()); try { checkSforceSession(); results = sforce_port.update(new SObject[] { account }, sh, arh, mruh, afth, dh, pvh, eh, dih); for (SaveResult result: results) { if (!result.isSuccess()) { for (Error err: result.getErrors()) { FileLogger.warn(companyProfile.getCustomerEntity() + ",[SF] The Parent Account Update failed because: " + err.getMessage() + " - " + err.getStatusCode()); } } } } catch (ApiQueryFault e) { ApiQueryFaultHandler(e); } catch (ApiFault e) { ApiFaultHandler(e); } } } else if (qr.getSize() == 0) { FileLogger.warn(companyProfile.getOwnerEntity() + ",[SF] Unable to locate this Parent Account when establishing Parent account"); } else if (qr.getSize() > 1) { FileLogger.warn(companyProfile.getOwnerEntity() + ",[SF] Located multiple Parent Accounts with this ID when establishing Parent account"); } }

 

Best Answer chosen by Admin (Salesforce Developers) 
rfisher000rfisher000

There are too many places for me to float around and try to figure out where all the validations, edits, exceptions, rules, and triggers are.

 

So I find this:

 

Rule Name

Child_Account_cannot_be_Parent_Record

Active

 

Error Condition Formula

AND( Parent.Name <> NULL, $RecordType.Name = "Parent" )

Error Message

Child Accounts cannot be "Parent" Account Record Type (Additional Information Section Below).

Error Location

Top of Page

Description

If an account is a child site, the record type cannot equal "Parent".

Created By

Nick Dempsey, 7/7/2009 10:11 AM

Modified By

Nick Dempsey, 7/7/2009 10:18 AM

 

Yet another example of poor DBA & Developer communcation.

Message Edited by rfisher000 on 08-06-2009 07:16 AM
Message Edited by rfisher000 on 08-06-2009 07:17 AM