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
BobUBobU 

My first S-control doesn't work - older API

I'm trying to add a function to an existing S-control that will count the number of times a form is printed from a custom object. ... <script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script> ... function incrementCounter() { var count = {!Progress_Note_v2__c.Number_of_times_Printed__c}; ++count; var update = new Sforce.Dynabean("Progress_Note_v2__c"); update.set("Id", "{!Progress_Note_v2__c.Id}"); update.set("Progress_Note_v2__c.Number_of_times_Printed__c", "count"); var saved = sforceClient.Update(update); } Thanks in advance
werewolfwerewolf
OK, well, first I'd suggest you get the firebug addon to Firefox to debug the problem.  If you can you probably will want to transition that Scontrol to a non-beta version of the AJAX toolkit, because what you've got there is really old.  The transition should be very straightforward.
BobUBobU
Firebug gives the error Program_Note_v2__c.Printed_number_of_Times__c is undefined. Is there any reason I can't use the current API and the old one at the same time in the same S-control?
werewolfwerewolf
Did you check to ensure that that field actually exists?  Does the user you're logging in as have the rights to view that field in Field Level Security?  Also, make sure your cases match -- "Printed_number_of_Times__c" has some weird capitalization there.  Use Force.com Explorer to look at your data model and examine that object.

You should be able to use the old beta Ajax toolkit and it should work just fine, but the new one is much easier to code in and use.