From past few days I have been working on requirements that involve getting user Input and then taking an action.
In most of them I had to get user input through browser script and call business service to apply business logic and condition to get the work done. I feel this is quite an inefficient way to do things.
Let me discuss one requirement with you guys and see if we can find a better solution
Requirement:
- We have Service Request as Parent BC and Activities as Child BC.
- Of all the child activities related to a particular Service Request only one should have status as ‘Final Solution’. When user sets the status as ‘Final Solution’ of an Activity then we should check if there is already an ‘Activity’ with status as ‘Final Solution’.
- If yes, then user should get an OK and Cancel Dialog box asking “Do you want to mark this Activity as Final’.
- If user clicks on ‘Yes’ then old activity with ‘Status’ as ‘Final Solution’ should be changed to ‘Interim Solution’ and this new activity should be marked as ‘Final Solution’.
- If user clicks ‘No’ then the current activity should be marked as ‘Interim Solution’
Phew ….. I hope I am able to make it as simple as possible.
Solution:
In applet browser script Applet_PreInvokeMethod have the following logic
if(name == “Write Record”)
{
Call BS to check if there are multiple records with 'Status' = 'Final Solution'
(In BS we will have loop through records to see if there are multiple records as the current record is also committed)
if (Multiple Record == True)
{
confirm(“Do you want to make this as final solution”);
if( User Choice == “OK”)
Call BS again to set other record as 'Status' = 'Interim Solution'
else
Call BS and set this record as 'Status' = 'Interim Solution'
}
}
Problems:
I really don’t like to call BS from browser script as it is inefficient and hard on performance.
I know this is not an ideal solution for this requirement. I am trying to find a more optimal solution for this requirement and If I am successful I will share it with you guys.
According to me in an ideal solution:
- We wouldn’t be calling BS from Browser Script (definitely not 2 times)
- Browser script will only contain code showing msgbox
- We wouldn’t have to loop for the records in BS
If any of you guys think you already have an answer then please share it with us all or I guess we will have to wait till I am able to figure out something.


