Wednesday, July 27, 2011

Child Field Read Only depending on Parent Field Value

Sometimes it happens that you get a very simple requirement to implement and in a single glance you say, "Well, this is very easy to implement" and when you actually see the result on the UI after the configuration you have done, you start scratching your head to find out the reason for not getting the result as per the expectation.

Today, I am going to discuss a very simple requirement you might have faced earlier.

I have two applet exposed on the UI: 1) Opportunity Form Applet 2) Quote List applet.
Opportunity being the parent applet and quote as the child as per below screen shot.

The simple requirement is to make "Comments" field on Quote List Applet editable, if and only if Sales Stage of Opportunity = Data Entry.

very simple isn't it! Anyone can easily say, go and use "Field Read Only Field" user property at Quote business component and you are done. I reacted to it in the similar manner and followed the below steps:
1. Pull "Sales Stage" value on Quote BC.
2. Create a calc field to set to Y, if Sales Stage = "Data Entry"

3. Create a BC User property, Field Read Only Field based on calc field.

Compile the SRF.

Navigate to Opportuity -> Quote view to verify the results. I created an Opportunity record, set the Sales Stage to "Data Entry" and then created a Quote record. "Comments" field was editable. Then I changed the Sales Stage to "Submitted" and per configuration I was expecting the "Comments" field to be read only, but to my surprise, it was not. Still, I was able to edit the field.

It might happen that change of "Sales Stage" at the Opportunity level is not getting reflected at the quote level. Let me try running a blank query (Alt+Q, then enter) to refresh and now..... yes, "Comments" field get read-only. So, basically the problem is, Quote BC is not aware of the change in Sales Stage at Opportunity level, unless you refresh it.

(Note: this is not the case with "Parent Read Only Field" user property. Change at parent field immediately gets reflected at the child level.
You can refer this post for more details.)

Now, the problem here is to get the Quote list applet refreshed, if some change happens at Opportunity. One might point out that you should have "Immediate Post Changes" as True for "Sales Stage". But, keep in mind that "Immediate Post Changes" will only refresh the fields of the same business component, not of the child BC.

One solution, I can think of is to refresh the Opportunity business component in such a way that it should not loose the record context and consequently, Quote BC will automatically gets refreshed. But, I didn't want to do the scripting on Opportunity WriteRecord event, just to refresh the Quote BC, something like:

function BusComp_WriteRecord ()

TheApplication().GetService("FINS Teller UI Navigation").InvokeMethod("RefreshCurrentApplet", TheApplication().NewPropertySet(), TheApplication().NewPropertySet());

So, I found a better way to achieve to refresh the Opportunity form applet. Just create the following user property on the Opportunity applet:

Compile the SRF and check the result on the UI. Voila, everything is working as desired now.



  1. its very interesting gaurav. Nice post, all d time production system will give new troubles with weird scenarios.

  2. Gaurav,

    Thanks for your service to siebel world. You should continue your service. I didn't see any recent post. Can we avoiod the script with the following user property.

    Named Method "WriteRecord", "INVOKE", "Quote", "RefreshRecord"

  3. Hi Siebel_learner,

    I tried it already but my observation was, you can't capture BC's event like WriteRecord, NewRecord in Named Method user property at BC level. But at the applet level, you can. So the solution I posted works well.


  4. Gaurav, here i think we can se thte link specification property to true at the parent field, can create cal filed at child bc with an expr like this.

    expr: iff(ParentFieldValue("FieldName")="Approved","Y","N")

    any how using the link specicagtion propery will pass the changes to child bc using link. then we can use the cal field @ field user property to make the field editable/read only........

  5. This solution works well with Parent applet as Form and Child Applet as list. When used on a view with Parent and child both as list applets, navigating to next record does not happen with the first step-off (because the record is being refreshed) but user will have to step off again.