Wednesday, November 9, 2016

Writeback with dropdown feature in OBIEE Report

In this blog we will see how to enable Writeback in OBIEE and one example like where users will be given option to choose values from dropdown to select any one and update in backend rather than typing in freeform text field in the OBIEE report. We will use Jquery to achieve it.
Below are the high level steps to enable write back in OBIEE.
·         File level configurations
·         RPD changes
·         Report changes

File level configurations

Step 1: Edit instanceconfig.xml
Here is the path to find instanceconfig.xml file
<Middleware>/instances/instance1/config/OracleBIPresentationServicesComponent/coreapplication_obipsn
And add below line under <DSN>
<LightWriteBack >true</LightWriteBack >
Step 2. Create WriteBack template  
We need to provide a template to the BI Server so that it will handle the writeback operation based on logic provided in template.
And place this template in below location in the Middleware server.
<Middleware>/instances/instance1/bifoundation/OracleBIPresentationServicesComponent/coreapplication_obips1/analyticsRes/customMessages

 Sample template code

<?xml version="1.0" encoding="utf-8" ?>
<WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
<WebMessageTable lang="en-us" system="WriteBack" table="Messages">
   <WebMessage name="Update_Comments">
     <XML>
      <writeBack connectionPool="Oracle Data Warehouse Connection Pool">
          <insert> </insert>
          <update>UPDATE EMPLOYEES set COMMENTS='@2' WHERE EMP_NAME='@1'</update>
<!-- Identify the columns that are to be referenced. We can use the column position like @1 for first column, or by column id as you see them in the XML definition/Table view. -->
        </writeBack>
      </XML>
    </WebMessage>
</WebMessageTable>
</WebMessageTables>


And name it like anything let say WriteBackTemplate.xml and copy to customMessages folder in the server.  

RPD Changes

Step 3: Enable Write Back in the RPD logical column
Navigate to to BMM table and expand column which you want to use for writeback
And enable the Writable checkbox under general table of logical column.










 
 
 
Step 4: Set Read/Write permission to Writable column
Navigate to Subject Area-> Presentation Table-> Writeable column (here column is comments in our example)

Double click on Permissions and select Read/Write for the application role for which you like to enable writeback feature










 






 






 
 
Here for BIAdministrator Read/Write permission enabled on this writable column.So that any user with this application role can writeback data from obiee report.

Step 5. Allow “Execute Direct Database Request” to database.
We need to set the permission to application role so that user with role should be able to contact database for insert/update data in backend.

Navigate Manage > Identity > Application Roles > BIAdministrator > Permission>Query Limits tab
And select “Execute Direct Database Requests” to Allow for the Database where in which you writable table or column    .




















 





Step 6. Disable Cacheable option for physical table.
Navigate to Physical Table and uncheck Cacheable checkbox.

Step 7. Grant Writeback privilege to Apllication Role or Users
Login Analytics and navigate to Administrator->Manage Privileges
And search for Write Back property and “Write Back to Database”
Grant access to BIAdministrator role 


Report Changes


Step 8. Create a OBIEE report
Create a report on this subject area and pull employee name and comments and another dummy column (Select Comment)

Note: Here Comments is the real write back column.whatever the value we select from the dropdown will be updated into this writeback column.
 


 






 


Here we will use the JQuery to display drop-down on "Select Comment" column
 
Edit formula and add below code.

'<select id="user_comment" onchange=obipswb.Grid.Change(event)>
<option value="No Comment">Select Comment</option>
<option value="Good">Good</option>
<option value="Bad">Bad</option>
</select>'
 













Make sure you selected checkbox for “Contains HTML markup”.

On clicking OK then it thrown error as 






We can ignore this error and proceed further.

Next override default data format to HTML.




Now enable Writeback to the Comments column










 


Create Table view and place this drop down column at second position in view (since we used @2 to update the value in the backend table).
Open table properties and provide WebMessage name (This should be taken from your WriteBackTemplate.xml).



Check the report to test WriteBack feature.



















Once you select any value from dropdown  then Apply button will be enabled and record can be updated on clicking apply. Note that drop-down column will not be updated with value you selceted and you can only see this value in the next column "Comments" which is write back column.ON clicking apply report will be refreshed and new value will be displayed on report.

12 comments:

  1. Hi Aravind ,

    Very nice blog , it really helps one of my Writeback requirement.

    However I have a questions about the drop down option , once we select the option and click on Apply does it display on the report.

    As per your example Aravind and I selected option as "Good" and click on Apply ...what happen next , it just updates the database and shown in the report as well??

    In my case it just updating the database but not showing the updated value in the report.


    Thanks,
    Praveen.

    ReplyDelete
    Replies
    1. Praveen,
      Did you ever get the drop down to work? Did you have to make any server side changes so that the column formula can take the code that Aravind showed?

      Delete
    2. Yes Praveen, Report will be refreshed with new value that you set through dropdown

      Delete
  2. hi,

    its possible use writeback with Direct Database Request?

    thanks

    ReplyDelete
  3. Hi Aravind,

    I have successfully implemented the writeback in obiee 12c but the dropdown feature is not working.
    Is there any workaround?

    'Error:
    Error Codes: OAMP2OPY:OPR4ONWY:U9IM8TAC:U9IM8TAC:U9IM8TAC:U9IM8TAC:OI2DL65P:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. (HY000)
    State: HY000. Code: 43113. [nQSError: 43113] Message returned from OBIS. (HY000)
    State: HY000. Code: 27002. [nQSError: 27002] Near <<>: Syntax error (HY000)
    State: HY000. Code: 26012. [nQSError: 26012] . (HY000)
    SQL Issued: {call NQSGetQueryColumnInfo('S*LECT S*lect Comment Good Bad FROM "Hyp Writeback"')}
    SQL Issued: SELECT S*lect Comment Good Bad FROM "Hyp Writeback"'

    ReplyDelete
    Replies
    1. You able to write back without drop down if my understanding is correct.

      Which browser are you using ?
      What is drop down code you have used?

      Hope you selected checkbox for “Contains HTML markup” and override default data format to HTML in drop down column formula .

      Delete
  4. I selected checkbox for “Contains HTML markup” But I didn't find override default data format to HTML. We are getting an error as "Formula syntax is forbidden because it contains client script" when we are trying to use the code in edit formula and we are using OBIEE 12c.Am I missing anything?

    ReplyDelete
    Replies
    1. Updated post ,now you can see where to Override this column data format to HTML.

      Column Properties--> Data Format --> Override Default Data Format

      Delete
  5. HI is there a way that we achieve the write back with one Column, We Just need to show the drop down or need to populate drop down inside the write back column.

    ReplyDelete
  6. Does anyone ever found solution to "Formula syntax is forbidden because it contains client script" error?
    Thanks

    ReplyDelete
    Replies
    1. Ignore this error and overwrite Default Data Format to HTML then it should work.

      Delete
  7. Thanks for sharing the post. I am able to implement this succesfully however when i am exporting data into excel i can see dropdown values instead of updated value. Is there any way to export only updated value instead of all dropdown values. Need your advice badly.

    ReplyDelete