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
chornbeckchornbeck 

How to trigger a field update with an s-control?

I have an S-control (in this case, it enacts a SkypeOut phone call for the lead...) that I would like to trigger a field update on user click.

I have a custom field named Times_Called that I need to increment by +1 each time the s-control button is pressed, thereby tracking the number of times the lead has been called.

Also, a little fancier, but each time the s-control button is pressed, I need it to be disabled for 8 hours afterwards (to give the user only "fresh" leads..)


If anyone can shed any light on either of these topics, it would be greatly appreciated!


zero1578zero1578
I am not sure that it would do exactly what you want, but the field increment is really easy.  The tough part would be disabling the field for X hours.  If you want to disable the editing of a field you would need a way to reference the time the field became disabled and the the time it is available for editing again, and this would have to be done at the time the page loads probably.
 
 
Create a field that stores the time the field will be reactivated.
In your s-control, call a custom function that takes the current value of the field you want to update, increment it by 1.  Set the custom "time until reactivated" field time to be a calculation of 8 hours or whatever timespan you want to cover, and then perform an update on the object to set the new field value and perform refresh on the parent window so you see the new values.
 
Create another function that is triggered onload of your scontrol.  Once the Scontrol is done loading, have it check if the field value for your re-activated time has passed or not.  If it hasnt then instead of just displaying the button, find it by its ID and either disable it or make it invisible.
 
Ugly-mode but it would work, at least without knowing/seeing more of what you are trying to do this with.