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
MathieuMathieu 

Need help with an S-Control

Hello,
 
I was wondering if someone could head me into the right direction, possibly some samples on how to accomplish the following 3 tasks.  I only have a basic knowledge base of Javascript (enough for simple website functions) but have been programming in VB for over 10 years.
 
1.  I have 2 objects.  Service Timecard and Service
 
Service Timecard is from the Time Tracking app in AppExchange and I've customized it to have a section where I can specify some invoice-specific info such as the service code to use for billing and billing price.  The service code to use is a Lookup control to the "Service" object that contains the services (Service Code, Service Description, Base Price).
 
What I'm trying to achieve as when a user selects a service code from the "Lookup" control that the "billing price" field on the Service Timecard object is automatically filled with the "base price" value of the selected service.
 
That's one of the things I'd like to accomplish.
 
2.  I have a "Lookup" field on the Service Timecard object that links that timecard to an existing "In Progress" Invoice object.  What I'd like to be able to do is from the Invoice object, under the "Service Timecard" related list, is be able to add multiple existing "Timecards" from a list by checking the ones I want and have the Invoice field on those timecards automatically updated with the current invoice's ID/Number.
 
And last but not least...
 
3.  On the Invoice object, I'd like an S-Control as a button that when clicked would update the Invoices "Amount" field with the Sum of the amounts on the related Service Timecards.
 
So, is all this possible?  And, is it too complicated to even be worth trying?
 
Thanks everyone,  I thank you all in advance for any help you can throw my way.
 
 
Greg HGreg H
Hi Mathieu,
 
Your three requests all seem doable but in my opinion would require significant coding.  This is primarily due to the fact that you cannot currently use sControls on the edit pages of any object.  Since you would like to use lookups on your first two requests, you would literally need to replicate the edit screens for those two business needs as sControls and then access those sControls via override on buttons from the current detail screen.  This can be done in AJAX and I suggest you begin by reviewing all the documentation for the describeLayout() API call.
 
Your third request is bit easier to code.  To begin with you should create an sControl to replicate a button and place that sControl on the detail screen for your Invoice object.  Upon click of your sControl button, you would execute the code to find all related Service Timecards for that Invoice and then update the Amount on your Invoice to be the sum of all Service Timecards.  I actually did something similar to this for a client but I cannot share the code here.  If you want to give this a shot and let me know when/if you encounter issues I would be happy to help.
 
Hope this can get you started,
-greg
MathieuMathieu

Thanks for the info Greg,

 

I'll give it a shot on number 3.