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
mr.sollismr.sollis 

s-control help - easy for gurus

my question is two fold:

1) Can I excecute an s-control on the create/edit page layout OR on save/edit
2) what is wrong with the code below for an js s-control, is there an easier way to accomplish this:

<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script language='text/javascript'>
try {
    var qr = executeQuery("SELECT Auto_Tracking_Code__c FROM Campaign ORDER BY Auto_Tracking_Code__c DESC");
    if(qr != null) {
        var campNext = parseInt(qr.records[0].get("Auto_Tracking_Code__c"))+1;
    } else {
        var campNext = 4000;
    }
} catch(error) {
    campNext = "Unknown";
}
document.write(campNext);
</script>
werewolfwerewolf
1) Can I excecute an s-control on the create/edit page layout OR on save/edit

Not really.  Although you can theoretically create a custom button that redirects the edit page to your Scontrol post-save, this is much easier done with an Apex trigger, not an Scontrol.

2) what is wrong with the code below for an js s-control, is there an easier way to accomplish this:

executeQuery is not a function.  Try sforce.connection.query instead.
mr.sollismr.sollis
Thank you for the help.  Not sure where I had that funciton.  Changing to the ajax object you suggested worked perfectly.

A few more related questions: 

1) Is it possible to have a custom link on and edit view that could be clicked and have it populate a field with a value calculated from the s-control logic (in the edit/create view)
2) Triggers are only available on Platform edition as I understand it, or can they be used on Enterprise edition as well?

Thanks again for your help.


werewolfwerewolf
1) Is it possible to have a custom link on and edit view that could be clicked and have it populate a field with a value calculated from the s-control logic (in the edit/create view)

Yes, you could have your Scontrol precreate the object with the necessary values and then navigate to the newly created object's edit screen.  That's probably the easiest way.

2) Triggers are only available on Platform edition as I understand it, or can they be used on Enterprise edition as well?

They're available in Enterprise Edition and up, as well as the platform editions.