Siebel Open UI >  Open UI WriteRecord Does Not Save Data in Browser Script even with BusCompAccessLevel = All

Open UI WriteRecord Does Not Save Data in Browser Script even with BusCompAccessLevel = All

ACTUAL BEHAVIOR  
------------------------------


After upgraded to 8.1.1.9 Open UI, the bc.WriteRecord() in browser script does not save data even with BusCompAccessLevel = All.
We have the following code, triggered by a minibutton, on an Contact Activity List Applet, in Pre_InvokeMethod:

switch(name)
{
case "AddComment":
{
var bc = this.BusComp();
var currentComment = bc.GetFieldValue("Comment");
bc.SetFieldValue("Comment", "New Comment::"+currentComment);
bc.WriteRecord();
return ("CancelOperation");

}
default:
{
return ("ContinueOperation");
}
}


This code SHOULD set the value of the currently selected Activity to add 'New Comment::" to the beginning of the existing comment. 

In Open UI, however, when we step off the screen tab and return back to this applet, the value has returned to its original value.

Additionally, the cursor remains a 'Busy' cursor for approximately 15 seconds. 

EXPECTED BEHAVIOR
------------------------------
In Open UI,  this code should set the value of the currently selected Activity to add 'New Comment::" to the beginning of the existing comment  and save the changes to the database so that even after step off the screen tab and return to this view, the changes would be still be displayed on the UI.


STEPS
-----------------------
The issue can be reproduced at will with the following steps:
1. Log into Siebel Open UI
2. Go to Contact Activity List Applet
3. Click the AddComment button, and the Comment field is updated with "New Comment::" to the beginning of the existing comment.   But when step off the screen tab and return, the value has returned to its original value.
Additionally, the cursor remains a 'Busy' cursor for approximately 15 seconds. 

BUSINESS IMPACT
-----------------------------
The issue has the following business impact:
Due to this issue, users cannot save the data

CAUSE

The behavior is a new product defect and logged Bug 17019287 WRITERECORD IN BROWSER SCRIPT WITH OPEN UI GENERATES ERRORS to address the behavior.
 
Here are the steps to reproduce the behavior inhouse.
1. Add below script to Contact Activity List Applet:

function Applet_PreInvokeMethod (MethodName) 

  switch(name) 
  { 
  case "AddComment": 
  { 
  var bc = this.BusComp(); 
  var currentComment = bc.GetFieldValue("Comment"); 
  bc.SetFieldValue("Comment", "New Comment::"+currentComment); 
  bc.WriteRecord(); 
  return ("CancelOperation"); 
  } 
  default: 
  { 
  return ("ContinueOperation"); 
  } 
  } 

}

2. Add applet user property to enable the button 
Name: CanInvokeMethod: AddComment 
Value: TRUE 


3. Add minibutton and expose on the applet 
Name =AddComment 
Method Invoke = AddComment 

4. compile the changes. 

5. Set BusCompAccessLevel = All in the cfg file under [InfraUIFramework] for dedicated client, or in the server parameter for thin client 
  http://docs.oracle.com/cd/E14004_01/books/Secur/Secur_AccessControl32.html 

6. Go to Contacts > Activities view, click the Add Comments button, and the error occurs 
[1]Field '%1' not found in BusComp. 
[2]Field '' does not exist in definition for business component 'Action'.


7. Note the Comments columns is updated with "New Comment::"

8. Click Ok to close the error popup

9. Click any screen tab and go be to Contact Activity List Applet, note changes to Comments field is not saved.
 

SOLUTION

Bug 17019287 has been fixed in 8.1.1.11.15_8.2.2.4.15 (IP 2013 patchset 15) , 8.1.1.14.4_8.2.2.14.4 (IP 2014 patchet 4) , 8.1.1.15_8.2.2.15 (IP 2015)  

If you cannot apply the above fix,  then please consider the below two workarounds:

Workaround 1:  Save the changes in server scripts.
In the applet browser script:

var psInputs = TheApplication().NewPropertySet();
var bs = TheApplication().GetService("MAHP Activity Comment Popup BS");
var psOutputs = bs.InvokeMethod("AddComment", psInputs);

var bc = this.BusComp();
var sComment = bc.GetFieldValue("Comment"); 

TheApplication().SetProfileAttr("AddCommentText", sComment);
return ("ContinueOperation");


This allows control to fall over to the applet server script:

var strAddCommentText = TheApplication().GetProfileAttr("AddCommentText");

var bc = this.BusComp();
bc.SetFieldValue("Comment", strAddCommentText);
bc.WriteRecord();

TheApplication().SetProfileAttr("AddCommentText", "");

return (CancelOperation);




Workaround 2: Instead of using bc.WriteRecord) method, please invoke the WriteRecord method on the applet as below:

var bc = this.BusComp();
var currentComment = bc.GetFieldValue("Comment");
bc.SetFieldValue("Comment", "New Comment::"+currentComment);
  // bc.WriteRecord();
this.InvokeMethod("WriteRecord"); 
return ("CancelOperation");
 
Reference
 
BUG TYPE CHOSEN
===============
Code

WHAT IS THE DESIRED BEHAVIOR?
=============================
In Open UI,  the WriteRecord method in Browser Script should set the value of
the currently selected Activity to add "New Comment::" to the beginning of
the existing comment  and save the changes to the database so that even after
step off the screen tab and return to this view, the changes would be still
be displayed on the UI.

WHAT IS THE ACTUAL OR UNEXPECTED BEHAVIOR?
==========================================
In Open UI, when the WriteRecord method in Browser Script is triggered, the
below error occurs:
[1]Field '%1' not found in BusComp.
[2]Field '' does not exist in definition for business component 'Action'.

Note the Comment field is populated. Click Ok to close the popup error.
When step off the screen tab and return back to this applet, the value has
returned to its original value.

Additionally, the cursor remains a 'Busy' cursor.

The behavior doesn't occur in HI client

INTERNAL REPRO
==============
Yes

REPRO_STEPS
===========
1. Add below script to Contact Activity List Applet:
function Applet_PreInvokeMethod (MethodName)
{
switch(name)
{
case "AddComment":
{
var bc = this.BusComp();
var currentComment = bc.GetFieldValue("Comment");
bc.SetFieldValue("Comment", "New Comment::"+currentComment);
bc.WriteRecord();
return ("CancelOperation");

}
default:
{
return ("ContinueOperation");
}
       }

}
2. Add applet user property  to enable the button
Name: CanInvokeMethod: AddComment
Value: TRUE


3. Add minibutton and expose on the applet
Name =AddComment
Method Invoke = AddComment

4. compile the changes.

5. Set  BusCompAccessLevel = All in the cfg file  under [InfraUIFramework]
for dedicated client,  or in the server parameter for thin client
  http://docs.oracle.com/cd/E14004_01/books/Secur/Secur_AccessControl32.html

6. Go to Contacts > Activities view, click the Add Comments button, and the
error occurs
[1]Field '%1' not found in BusComp.
[2]Field '' does not exist in definition for business component 'Action'.
7. Note the Comments columns is updated with "New Comment::"
8. Click Ok to close the error popup
9. Click any screen tab and go be to Contact Activity List Applet, note
changes to Comments field is not saved.

DESCRIPTION
===========

REPRO WITH STANDARD SRF
=======================
No

REPRO_CLIENTS
=============
Web client / thin client (server)
Dedicated client against the server database
Dedicated/Remote client against the local or sample database

MARK ALL APPLICATIONS WHERE APPLICABLE
======================================

CHAMP TYPE
==========

APP SERVER OS (SEBL)
====================
N/A

BROWSER (SEBL)
==============

CLIENT OS (SEBL)
================

INTERACTIVITY (SEBL)
====================

PRIMARY AFFECTED LANGUAGE (SEBL)
================================
ENU

WEB SERVER APP (SEBL)
=====================
N/A

WEB SERVER OS (SEBL)
====================
Other