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
warrenlesterwarrenlester 

Contract create gives error: custom validation violation

I have been using an S Control for some time now, but since winter 07 was deployed it has been giving us this issue on and off.

I use the following javascript to create contracts:

var recContract = new Sforce.Dynabean("Contract");
recContract.set("AccountID","{!Opportunity.AccountId}");
recContract.set("ContractTerm",escape_amp(getValue("Warranty")));
// recContract.set("status","Draft");
var shipDate = fixDate(getValue("ShipDate"));
recContract.set("StartDate",shipDate);
recContract.set("covers__c","Warranty");



var recsContract = new Array(1);

recsContract[0] = recContract;
alert(recsContract);
var saveContract = sforceClient.Create(recsContract);
if(saveContract[0] == null)
throw("Contract Create Failed - " + saveContract.toString());
if(saveContract[0].success != true)
throw("Contract Create Failed - " + saveContract[0].errors[0].message);
 
The array used for the update seems to be well formed, but it always returns an error.

Although this is using beta 3.3 of the ajax toolkit, it was previous working and I can find nothing in the release notes that describe any relevent changes.

Any help would be appreciated.

Warren Lester
TCAdminTCAdmin
Hello Warrenlester,

Your code seems to be correct but your organization has a validation rules that is preventing it from being saved. If you go in to your organization and go to Setup | App Setup | Customize | Contracts | Validation Rules you should see a list of ones in your organization. I would disable them one at a time until it lets me save the record. If you alert your full error you should see what the validation error message is.
TCAdminTCAdmin
Warrenlester,

What you will probably want to do is update it to the most recent version of the API. If you are using the beta version and IE7 I know you will run in to issues. I'm not sure of the exact cause but by using the newest version you will probably resolve your issue. If you need assistance with it then please let me know.
warrenlesterwarrenlester

Hi Chris,

Your suggestion of validation rules was the first thing that I thought of. However, we have none as far as I know.

I agree, that I should update it to the latest version of the AJAX toolkit and API, but this is no mean feat. I will try the latest endpoint with the existing toolkit and see what happens.

 

Thanks

Warren