Wednesday, February 4, 2009

Required : A Field User Property

Siebel provides various ways in making any Field mandatory while saving the record. Some of the common ways we use in our daily Siebel implementation are :

a) "Required" property of BusComp's field. Setting this property to TRUE, made the field mandatory while saving the record.

b) "Required", a field user property which calculates an expression to decide whether the field should be mandatory or not. This is very useful for making field mandatory, conditionally.

c) Last one is writing script on "PreWriteRecord" event of business component.

I got the requirement to make "Spouse Name" field mandatory on the UI, when user checked the field "Married" to True.

The requirement sounds very simple but we should decide the best possible way to implement it. As I mentioned above, we can implement this requirement via two ways : first one is by writing code on PreWriteRecord event and the second one is by using "Required" field user property. Lets see the both implementation.

First Implementation - Scripting on PreWriteRecord() Event
if (this.GetFieldValue("Married") == "Y" && this.GetFieldValue("Spouse Name") == "")
{
TheApplication().RaiseErrorText("Spouse Name is a mandatory field");
}
Second Implementation - Required Field User Property
Create Field User Prop for "Spouse Name" field :
Name : Required
Value : IIf ([Married] = "Y", "Y", "N")
Compile the SRF by using one implementation at a time and see the difference.

Pros & Cons

1. Scripting solution is good if you need to show a customized message to the user, in case he forget to fill in the mandatory field. But scripting should be avoided as much as we can.

2. Using "Required" field user property is the recommended solution for such kind of scenarios.

.

12 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. hai gaurav we are expecting new post

    ReplyDelete
  6. thanks for you all time and i want to practice more with siebel escript can you give me much scenerios and if possible best solutions thanks

    ReplyDelete
  7. Required user property not working for some classes
    thanx naveen

    ReplyDelete
  8. The class of the underlying BC should be of the CSSBC Base Class for the user property to work.

    ReplyDelete
  9. Required user property when condition has a field that is numeric does not work.
    For example:
    Create field user property for "TRAVEL HOURS".
    Name: Required
    Value: IIf(([TRAVEL HOURS]<=0),"Y","N")

    I also tried:
    Value: [TRAVEL HOURS] = 0

    Value: [TRAVEL HOURS] <= 0

    I tried so many logical conditions for value, but the only one that works is when I check for NULL. This doesn't help me because I need to check if <= 0.
    I think I have to script and cannot use the user property.

    ReplyDelete
  10. If you ever face a problem that "Required" user property is not working as you expected, then try this:
    1. Close the web client.
    2. Compile the SRF again with "Auto-start web client" unchecked.
    3. Open the web client again, now it should work fine.

    ReplyDelete
    Replies
    1. thanks.I started web client as you said and that's work

      Delete
  11. Hi Gaurav,

    this user property is not working in case of pick applet when the step off the record for saving.

    Checked all the points BC class, compiling diff ways. no use.
    any idea. here.

    Siebel 8.1.1.7.

    ReplyDelete