+ Start a Discussion
Gracia SelinaGracia Selina 

Custom S-Control error - Create household for a contact

Hi all,

We are a small charity that use nonprofitforce as our database.
We have a tab for creating household for a contact and it's suddenly not working recently.

I have asked salesforce support and she said it is a Custom S control which is a custom coding. We are only a standard customer and do not have any developer support.

Can anyone please help?

Please find below the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js?browser=true" type="text/javascript"></script>
<script id="clientEventHandlersJS" language="javascript">
function initPage() {
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", true);

//Use this function as the entry point for your DHTML and JAVASCRIPT processing
function setup() {
//create household
var Household = new Sforce.Dynabean('ONEN_Household__c');
var HouseholdArray = new Array(1);
Household.set("Name","{!Contact.FirstName}" + " " + "{!Contact.LastName}" + " Household");    

var mailingstreet = document.getElementById('fixMailingStreet').innerText;
Household.set("MailingStreet__c", mailingstreet );

Household.set("Recognition_Name__c","{!Contact.FirstName}" + " " + "{!Contact.LastName}");

HouseholdArray[0] = Household;    
//Call create on the Household
var HouseholdSaveResult = sforceClient.Create(HouseholdArray);
//if it worked, relate the Contacts to the household
if (HouseholdSaveResult[0].success == true) {

//get the object that was returned
CreatedHousehold = HouseholdSaveResult[0];
//create a Contact object for updating
var Contact = new Sforce.Dynabean('Contact');
var ContactArray = new Array(1);
//Set the Id

//Set the Household Id    
Contact.set("ONEN_Household__c", CreatedHousehold.id);
ContactArray[0] = Contact;    
//Call create on the Opportunity.
var ContactSaveResult = sforceClient.Update(ContactArray);
//if it worked, redirect to the Household
if (ContactSaveResult[0].success == true) {    
top.location.replace("/" + CreatedHousehold.id);

} else {
alert("Error updating Contact! " + ContactSaveResult[0].message);

} else {
alert("Error in creating household!");

<body onload="initPage()">
<div id="fixMailingStreet" style="display: none;">{!Contact.MailingStreet}</div>

Thank you.
Kind Regards

One possibility is that there has been a change in field requirements on the Account object. Has a new required field been added to the Account object? Or perhaps a new/updated validation rule?
Gracia SelinaGracia Selina
Hi Pigginsb,

Thank you so much for your reply.
I haven't added any required filed to the account object nor updated the validation rule.
This custom s control was created in 2008.
I'm not a programmer, just guessing that maybe the ajax/beta3.3 have been changed to newer version?
<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js?browser=true" type="text/javascript"></script>

Do you think that's the issue?