Problem: I need a function to lookup the description of a LOV provided its type and value
Solution: We address the problem in two steps:
Define a user object and make sure it is available for the session. One of the common ways of doing this is in Application object
Use the custom object to define a prototype for useful function(s) - in our case 'LookupDesc'
- Define a variable in the application script, for example: Siebel Life Sciences
- Write the custom business service 'COG Test Proto'
function MyAppFun()
{
// this is a dummy, but funny function.
}
[Service: COG Test Proto, Method: MyAppFun]
That's about it, now MyApp is ready to have some fun. Again, a quick service to test how things work.
A bit of theory on how it works:
- MyApp is defined as a variable in Application, the same is initialized in a business service. It does not matter what the function [MyAppFun] contains, we will not be using that anyway
- The prototype LookupDesc is defined as an extension of MyAppFun. Any object based on MyAppFun will have access to the LookupDesc functionality
- We invoke LookupDesc as an extension of the variable in the application object. There are other blogs out there who just use TheApplication = MyApp, but that practice is not encouraged as I understand
- When TheApplication().MyApp.LookupDesc is invoked, Siebel will look for the LookupDesc function for MyApp object. Since the functionality does not exist OOB, the prototype is consulted and in turn LookupDescFun function is executed.
If you are thinking this is an overkill, you may be right if this is all you want to do. Keep in mind that this coding practice will be more scalable, and ensures reusability.