A lot of readers have requested me to include real life scenarios with solutions. Hence I have been hunting for requirements on web which I can discuss with you guys. During my surfing yesterday I came across a requirement which I would like to share with you.
I am sharing it with you not because it has an interesting or complex solution but, to emphasize the fact that there are always several ways to achieve a things in Siebel and completing the requirement should not be your only goal as doing it in a wrong way can severely hamper the long term life of your application. You should always ask this question to yourself.
Is there a better way to do it?
Well now not wasting much of your precious time let’s get on with the requirement.
Requirement:
- On Service Agreement list applet we have a button ‘move to batch’
- User can select all contracts, or 1 or more contracts using CTRL button, and move these to his batch for executing renewals.
- User should not be able to add same contract twice in renewal batch for this ‘User key’ has been used and if user tries to do this he will get “Record with same values already exists” error
Here is the part of requirement that forced me to write this post.
- In eScript code I want to ignore or suppress this particular error and if this comes it should execute the code for next error.
My Thoughts:
This is absolute wrong way to do this requirement even if you can do it. What you should be doing is to do write your script in such a way that this error doesn’t come at all and there are several easy ways to ensure this.
Here is the approach I would have used to accomplish the requirement
Solution:
In the Applet server Script write the code to implement following logic (I am not providing the complete code).
var isRecord = BC.FirstSelected();
while(isRecord)
{
Call a workflow and pass the field values that are part of user key
isRecord = BC.NextSelected();
}
In the Workflow I would query for the record with the values that are passed.
If record is found then go to End step otherwise call the Business Service to create a new record or may be use Insert step and avoid all scripting all together.
The decision to use Insert Step or BS will depend on how complex the logic is to create the record.
If it is simple insertion then pass the values of the required field in the workflow and use it in insert step but if certain kind of data manipulation or validations are required then you can use a BS to do your job.
If you think there is another better way to do it then do let me know. Your comments are always welcome.



