Monday, April 6, 2009

BC Read Only Field v/s Parent Read Only Field : A Case Study

We got one requirement to make the Child and Parent Child Applet readonly in a view, if the GrandParent (the applet which is driving the visibility of the view) has got the Status = "Inactive". Sounds interesting, right?

Okayy, let me rephrase it and try to explain you with more details what exactly we want to see.

We have a View in which the following applets are exposed :
a) Accounts Form Applet - Parent
b) Service Request Form Applet - Child
c) Activities List Applet - Grandchild


Accounts applet has a field "Status" exposed on the UI and the requirement is that once Account Status = "Inactive", user cannot do any modification/insertion/deletion on Service Request and Activities applet. Both Child (Service Request) and Grandchild (Activities) applet should become readonly.

I can think of two different User Properties that we can use to achieve this. Lets see the both solution :

First Solution

So, the very first BC user property comes into mind is "BC Read Only Field", which just require a BC Field as a value and depending upon the field's value (Y/N), the BC become readonly. To achieve the solution with this user property, follow the below steps :

a) Create Calc field in Service Request BC:
Field Name : SRReadOnly
Calculated : TRUE
Calc Value : iif(ParentBCName() = "Account" AND ParentFieldValue("Status") = "Inactive", "Y", "N")

b) Create BC User Property in Service Request:
Name : BC Read Only Field
Value : SRReadOnly

c) Create Calc field in Action BC :
Field Name : ActivityReadOnly
Calculated : TRUE
Calc Value : iif(ParentBCName() = "Service Request", ParentFieldValue("SRReadOnly"), "N")

d) Create BC User Property in Action :
Name : BC Read Only Field
Value : ActivityReadOnly


e) Set Link Specification = True for "Status" field at Account BC.

Second Solution

The next BC User property that we can use here is "Parent Read Only Field", which can be used as follows :

Name : Parent Read Only Field: <_parentbuscompname>
Value : <_parentfieldname>


a) Create a calc field on Account BC :
Name : AccntInactive
Calc : TRUE
Calc Value : iif([Status] = "Inactive", "Y", "N")


b) Create a BC User Property in Service Request :
Name : Parent Read Only Field: Account
Value : AccntInactive


c) Create a calc field on Service Request BC :
Name : AccntInactive
Calc : TRUE
Calc Value : iif(ParentBCName() = "Account", ParentFieldValue("AccntInactive"), "N")


d) Create BC User Property in Action :
Name : Parent Read Only Field: Service Request
Value : AccntInactive


Compile the SRf after using each solution and observe the changes by setting Account Status Active/Inactive.

If you would compare the two solution, both looks same from configuration perspective as both require two calc fields and two user properties in all. But from scalability standpoint, second solution is better as you can easily use as many instances of "Parent Read Only Field" you want, in case Activities/Service Request need to show read only, when exposed under some other Parent BC like Opportunity, Quote etc. While in case of "BC Read Only field" you need to accomodate the business logic inside the calc field itself, as we can have only one instance of this user property at one time.


Third Solution

I can think of one more solution for this problem by, and I think the most efficient, by using both user property. Here it goes :

a) Create a calc field on Service Request BC :
Name : AccntInactive
Calc : TRUE
Calc Value : iif(ParentBCName() = "Account" AND ParentFieldValue("Status") = "Inactive", "Y", "N")


b) Create a BC User Property in Service Request :
Name : BC Read Only Field
Value : AccntInactive


d) Create BC User Property in Action :
Name : Parent Read Only Field: Service Request
Value : AccntInactive

Third solution, we can actually save one more calc field and solution is achieved by creating 1 Calc field and 2 user properties.

Your comments are most welcome, incase you have any other good ideas around this scenario.

Keep commenting !!!!!

.

8 comments:

  1. thank you Gaurav .

    ReplyDelete
  2. hai can you explain how to this scenerio iam not getting any idea
    A and B are two fields that A parent B is child
    having pick lists(static) and now when we check C field value true then constrain is happens other wise there is no contstraining between these fields
    like

    A field value show s contry (india , china ,japan)
    B field value is states(statesin india,statesinchina aswell)
    so There is field C has check box value (true/false)
    if you check C the constrain is happens otherwise can't between these fields
    can you give me some sort of idea.

    ReplyDelete
  3. A query....This user Property makes all records in child BC, READ ONLY but the New Record button on that child applet would be enabled or disabled? If i wish to make it enabled. what can i do?

    ReplyDelete
  4. @Miss J

    New Record button will be enable. These user properties will just make the existing records readonly depending upon the value of Calc field you have used.

    ReplyDelete
  5. Try using the Applet user property
    Name: CanInvokeMethod: NewRecord …Value: [AccntInactive] <> "Inactive"

    ReplyDelete
  6. solution 2 is wrong
    it should be
    Name: Parent Read Only Field
    Value: BC.Fieldname in parent
    Nagarjuna

    ReplyDelete
  7. Hi Anonymous, this is another way of using the same user property.

    1) Parent Read Only Field
    http://download.oracle.com/docs/cd/B40099_02/books/ToolsDevRef/ToolsDevRef_UserProps106.html

    2) Parent Read Only Field : BusCompName
    http://download.oracle.com/docs/cd/B40099_02/books/ToolsDevRef/ToolsDevRef_UserProps107.html

    It would work both ways.

    Cheers
    Gaurav

    ReplyDelete
  8. I guess for Sol 1. We need to turn on the link spec property for SRReadOnly as we are using its child applet "Activity".

    ReplyDelete