Monday 21 September 2015

Conditionally hide a field using PR file in siebel

Hi all,

Recently i had a requirement to hide a field conditionally based on the value of another field. This could be done using browser script but since we are using Open UI so we achieved it using
Physical Renderer file(PR). The arrpoach is preety simple.

1. Need to Identify the field depending on which to hide the other field or Hide same field.
2. Write the logic in PR file to hide the field.
3. Register the custom PR against the applet in Mainfest Administration.












The exact logic is :









Result
Field Active is hidden if the value is N, This can be modified for other requirement as well we just need to identify the correct element /field to hide, using inspect element.









PR file looks Like


if (typeof(SiebelAppFacade.LOYHideFieldPR) === "undefined")
 {
 SiebelJS.Namespace("SiebelAppFacade.LOYHideFieldPR"); define("siebel/custom/LOYHideFieldPR", ["siebel/phyrenderer"], function ()
 { SiebelAppFacade.LOYHideFieldPR = (function () { function LOYHideFieldPR( pm )
 { /* Be a good citizen. Let Superclass constructor function gets executed first */ SiebelAppFacade.LOYHideFieldPR.superclass.constructor.call( this, pm );
 /* Static List of Control Identifier which will be displayed in Carousel; */
 }
 SiebelJS.Extend( LOYHideFieldPR, SiebelAppFacade.PhysicalRenderer );
LOYHideFieldPR.prototype.ShowUI = function()  { SiebelAppFacade.LOYHideFieldPR.superclass.ShowUI.call( this );
 var pm = this.GetPM();
 var controls = this.GetPM().Get("GetControls");
 var cntrl = controls[ "ActiveFlag" ];
 var ActiveFlg = pm.ExecuteMethod( "GetFieldValue", cntrl );
 // alert(ActiveFlg); Test to check if value is retrieved or not
 if(ActiveFlg == "N")
 {
 $('[aria-labelledby = "ActiveFlag_Label"]').hide();
 $('#ActiveFlag_Label').parent().hide();
 } };
 return LOYHideFieldPR ; }());
 return "SiebelAppFacade.LOYHideFieldPR";
 });
}

Hope this was helpful..

7 comments:

  1. Hi,

    Need to Disable a button from an applet using Jquery in PR script from UI only. How can this be achieved.

    ReplyDelete
  2. Hello Lakshmi,

    you can use either

    $('#Button').attr('disabled','disabled'); //jquery

    here #Button is the id of button. or you can set visibility to hidden for the given button ,

    $("#Button").css("visibility", "hidden");//css

    Regards,
    Rahul

    ReplyDelete
  3. Hi, we have a requirement almost the same as this but the condition to hide a field will depend on the value of another field and not the field to hide. How to achieve this?
    Many thanks for your help.

    ReplyDelete
    Replies
    1. Hi, in addition to my comment the field to hide is a picklist field while the field to check for condition is a calc field. Is this possible?

      Delete
  4. Hi, When value is changed from N to Y, unless page is refreshed show/hide is not coming into picture. What is the solution on that? How can we refresh browser cache on change of field value.

    ReplyDelete
  5. Hello Van, you need to register field change event and call the code to hide control in that function.

    Something like
    this.GetPM().AttachPMBinding(“FieldChange”,onFieldChange )

    This code will be fired each time field change occurs

    ReplyDelete
  6. What is an outstanding post! “I’ll be back” (to read more of your content). Thanks for the nudge! 안전놀이터 순위

    ReplyDelete

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...