Friday, July 15, 2011

How to make all Child BCs read-only when Parent BC becomes read-only?

Today I am going to discuss one interesting requirement where you are required to make all the Child Business components read only as soon as the Parent business component becomes read-only.

Actual scenario goes like this:
As per the business requirement, we need to have the Opportunity business component read-only when Sales Stage is Approved. For this simple requirement we configure the BC User Property: "BC Read Only Field" based on a calculated field "OpptyReadOnlyCalc" as defined below:

User Property
Name = BC Read Only Field
Value = OpptyReadOnlyCalc

Field Details
Name = OpptyReadOnlyCalc
Calculated = True
Calculated Value = IIf([Sales Stage] = "Approved", "Y", "N")


This was working pretty fine, but complexity get added to it when we are required to make all Child business components read-only as well. Though the Opportunity record was coming read-only on the UI, but it was allowing us to create the child record as per below screen-shot:



You can see in the above screen shot (marked in Red), all the vanilla buttons i.e. Add, New, Delete are enabled. Requirement was to disable these buttons and user not allowed to do any operation on the child BCs as well as soon as Opportunity become read-only.

Solution:
To achieve this requirement, you are required to create two more BC user properties on Opportunity Business component.

User Properties

Name = Aspect Child BC ReadOnly: ReadOnly
Value = OpptyReadOnlyCalc

Name = Default Aspect
Value = ReadOnly



Thats it, compile the SRF and VoilĂ , now observe the difference on the UI.


If you want to learn about Aspect User Properties, follow the below link:
http://download.oracle.com/docs/cd/B40099_02/books/ToolsDevRef/ToolsDevRef_UserProps43.html
.


8 comments:

  1. Its not working with child bc,ie ir is in editable mode only

    ReplyDelete
  2. Rajesh,

    Aspect User properties only works on CSSBCBase class. Either your business component's class should be CSSBCBase or it's super class (or it's super class.....) should be CSSBCBase.

    Please refer the link I mentioned in the post for more details.

    Cheers
    Gaurav

    ReplyDelete
  3. why not to use parent read only user proprty. It will make parent BC as well as all child BC read only?

    Pravin

    ReplyDelete
    Replies
    1. Parent Read Only User property is mentioned on child BC. So you need to place it on all childs.

      Delete
  4. Error Message
    Back
    We detected an Error which may have occurred for one or more of the following reasons:


    Invalid search specification ''. Please continue or ask your systems administrator to check your application configuration if the problem persists.(SBL-DAT-00501



    it is throwing error why?

    ReplyDelete
  5. Parent Read Only user property is written under Child BC where it checks the value of some parent field's value. You need to put Parent Read Only User Property on all the childs. The above user property can be placed at Parent only. You do not need to place user properties on all the childs.

    ReplyDelete