6 Replies Latest reply: Mar 11, 2013 9:59 AM by 996084 RSS

    Making a field Mandatory based on another field Value

    CSK
      Hi All,

      I need to make a field mandatory based on other field value in iExpenses. Let me give more details


      In the iExpenses lines page (/oracle/apps/ap/oie/entry/lines/webui/CashAndOtherLinesPG) if the Expense Type choosen as Hotel then in
      the details page (  /oracle/apps/ap/oie/entry/lines/webui/DetailsPG ) field +"Expense Location"+ needs to be mandatory field.


      Please advise your suggestions.


      Thanks,
      CSK
        • 1. Re: Making a field Mandatory based on another field Value
          keerthioaf
          Hi ,

          Your Logic should be

          1 ) Put the "Expense Type" value in a session variable
          2 ) Get the session variable value ( Expense Type ) in /oracle/apps/ap/oie/entry/lines/webui/DetailsPG
          i.e In PR of DetailsPG controller get the session value and compare the session value with the string variable ( Initialize a string variable with name Hotel)
          3) If they are equal then get the beanID of "Expense Location " and set required property as true .

          Note : when you navigate away from the page ( DetailsPG ) you need to remove the session variable so that next time when you change
          expense type it should be able to pick the latest value .

          Keerthi
          • 2. Re: Making a field Mandatory based on another field Value
            CSK
            Hi All,

            Now we have a change in the requirement.

            In iExpenses we have details page, In that we have a Drop Down Field Called "Expense Type" in that if i choose value as "Hotel and Lodging" then i need to make the Expense Location field which is in the same page as Mandatory.

            So i hope i need to go for a CO Extension here Please advise what is the code i can use in process request to get the Expense Type field and to make the Expense Location Field Mandatory.


            Thanks for you time and consideration.
            • 3. Re: Making a field Mandatory based on another field Value
              keerthioaf
              Hi ,

              In simple way if you wish to handle this , then your approach could be

              1 ) On click of a button you can get the value of "Expense Type" if its equal to "Hotel and Lodging" then

              2 ) throw an exception saying Pls enter the value for "Expense Location field"


              Eg :

              if(pageContext.getParameter("buttonID") !=null )

              {
              get the Expense Type value here and where ever its equals to Hotel and Lodging

              then , if( Expense Type == Hotel and Lodging )

              {
              throw new OAException ("pls enter the value for Expense Location",OAException.INFORMATION);
              }

              }


              Alternatively you can also validate using Fire action but above method will easy to implement . Let me know if its not clear


              Regards ,
              Keerthi
              • 4. Re: Making a field Mandatory based on another field Value
                CSK
                Thanks Keerthi.

                Actually i need to get a message choice value in processRequest. if the value == Hotel and Lodging then i need to make Expense Location which is a MessageTextInput Field as Mandatory.

                I just tried the below code in my co in processRequest but couldn't get the value of message choice. Please see below my CO code and advise

                CO Code_

                public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
                {
                oapagecontext.writeDiagnostics(this,"### xxDetailsPageGlueCO PR...",4);
                super.processRequest(oapagecontext, oawebbean);
                OAApplicationModule am = (OAApplicationModule)oapagecontext.getRootApplicationModule();

                String Exp =(String)oapagecontext.getParameter("ExpTypeChoice");
                oapagecontext.writeDiagnostics(this,"### ExpTypeChoice value..."+Exp,4);

                OAMessageChoiceBean ExpTypBean = (OAMessageChoiceBean)oawebbean.findChildRecursive("ExpTypeChoice");
                oapagecontext.writeDiagnostics(this,"### ExpTypeChoice value1..."+ExpTypBean,4);
                oapagecontext.writeDiagnostics(this,"### Inside ExpTypBean Bean..."+ExpTypBean.getText(oapagecontext),4);
                }

                below is the output

                200]:EXCEPTION:[xxiExpenses.oracle.apps.ap.xxDetailsPageGlueCO6]:### xxDetailsPageGlueCO PR...
                [249]:EXCEPTION:[xxiExpenses.oracle.apps.ap.xxDetailsPageGlueCO6]:### ExpTypeChoice value...null
                [250]:EXCEPTION:[xxiExpenses.oracle.apps.ap.xxDetailsPageGlueCO6]:### ExpTypeChoice value1...OAMessageChoiceBean, localName='messageRadioGroup'
                [250]:EXCEPTION:[xxiExpenses.oracle.apps.ap.xxDetailsPageGlueCO6]:### Inside ExpTypBean Bean...11688
                • 5. Re: Making a field Mandatory based on another field Value
                  CSK
                  Keerthi and All,

                  Thanks i have resolved this.


                  Regards,
                  CSK
                  • 6. Re: Making a field Mandatory based on another field Value
                    996084
                    Would you be willing to share your resolution code?