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
bakumbakum 

Apex Code general algorhythm advice for beginner

Hi, I have a scenario I'd like to run by someone because I'm a bit confused and would rather not run down the wrong path...

Let's say I'm building an app to schedule classes.  So there's custom objects for Courses (which have a title, description, and number of days duration) and then Classes, which are scheduled courses, and which contain a lookup to the Course.  I'd like there to be a field in the CLASS object that allows the user to set a duration for the individual class, in case it is different than the standard (say they client wants to run a 3 day course in 2 days which happens a lot). 

What I'd like is that when the user completes the lookup form to choose the course that is to be scheduled, I'd like the duration field on the class form to be updated with what is set for that course in the course object. But then the user could over-write that if they wanted. 

Out in non-salesforce land I'd just throw a javascript "onchange" or something on the course field and then do a little ajax magic an voila.  But I'm not sure here how to get the onchange to happen.  Doesn't seem like it's apex code cause they supposedly doesn't let me opdate the UI.  But is it an s-control?  I dunno. 

Any help would be greatly appreciated.
Ron HessRon Hess
you would probably have to write a wizard (using scontrol code) which first collected the lookup data, then presented another input field with the duration data defaulted.

writing a wizard like that is a fair bit of work, when you have all the data you would then commit the record using ajax toolkit.
bakumbakum
Thanks, Ron.  I'll look into wizards.