This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 9, 2013, 9:00 PM
13 Posts

How to replace a value in multivalue field

  • Category: Debugging
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 8

I'm trying to replace an element in a multivalue field.  Sounds easy enough...I have the field from the document

var catStatus = doc.getItemValue("Status"); <--------multivalue field containing 5 elements
                print ("catStatus = " + catStatus); <-----------get back: catStatus = Avail,catStatus = Avail,catStatus = Avail,catStatus = Avail,catStatus = Avail (what's expected)
                print ("length of catstatus is " + catStatus.length); <---------------get back : length of catstatus is 5
                
                var bci:int;
                var selBC = sessionScope.get('selectedBarCodes' + i);
                print ("selected BC is " + selBC); <----------------------get back: selected BC is 20110155RAS-2
                print ("length of barcodes is "+ catBarcodes.length)<--get back: length of barcodes is 5
                for (bci=0; bci< catBarcodes.length; bci++)
                {
                print ("bci = " + bci); <----------get back: bci = 0 then bci = 1 (so it's a match)


                    if (catBarcodes[bci] == selBC)
                        {
                        print ("found bci match"); <---------get this back, so there's a match on bci = 1
                        catStatus[bci] = 'CO'; <------------------crash

Error while executing JavaScript action expression. For more detailed information, please consult error-log-0.xml located in c:/Lotus/Domino/data/domino/workspace/logs
09/09/2013 04:03:04 PM  HTTP JVM: com.ibm.xsp.webapp.FacesServlet$ExtendedServletException: javax.faces.FacesException: Error while executing JavaScript action expression
 

Any suggestions? Been knocking my head against the wall all day on this one.

Sep 9, 2013, 9:11 PM
366 Posts
What is the error in the log?

look in -->C:\Program Files (x86)\IBM\Lotus\Notes\Data\IBM_TECHNICAL_SUPPORT

 

might be different based upon your install, but sort by date and look for the stack trace in either the console log or the exec file and provide that.

Seems to be an issue with setting the array value.

Sep 9, 2013, 9:31 PM
13 Posts
Not telling much

Does error CLFAD0134E: Exception processing XPage request mean anything?

 

However, when you look at the crash it states:

Error while executing JavaScript action expression
put(int index,FBSValue value) not supported in JavaWrapperObject

I assume the put(int index) is the attempted replace of the indexed element for the field.  Is my coding correct?  Is there another way to replace an element in an existing multivalue field?  Currently I'm using

            catStatus[bci] = 'CO';  where catStatus is the multivalue field, and bci is set to 1. 

Jst for grins I also changed the code to catStatus[1] = 'CO  and it also crashed.

Any other suggestions?
      

Don't know what you mean by the "exec file"  Where's that?

Sep 10, 2013, 10:28 AM
54 Posts
try this

This should sove your probliem; just one solution.

var Field_Arr = new Array(document1.getItemValue("Fieldname"))
Field_Arr[0] = "new Value";
document1.setValue("Fieldname",Field_Arr)

Sep 10, 2013, 12:39 PM
13 Posts
Still getting error

I replaced my code with

print ("found bci match");
print ("catStatus = " + catStatus[bci]);
var Field_Arr = new Array(doc.getItemValue("Status"))
Field_Arr[0] = "new Value";
print ("field array is now assigned " + Field_Arr[0]);
doc.setValue("Status",Field_Arr)
print ("past crash");

I get this far in the log

selected BC is 20110155RAS-1
09/10/2013 08:25:38 AM  HTTP JVM: length of barcodes is 5
09/10/2013 08:25:38 AM  HTTP JVM: bci = 0
09/10/2013 08:25:38 AM  HTTP JVM: found bci match
09/10/2013 08:25:38 AM  HTTP JVM: catStatus = Avail

and this error

Error undefined (Error calling method 'setValue(string, Array)' on an object of type 'lotus.domino.local.Document [Static Java Interface Wrapper, lotus.domino.local.Document: lotus.domino.Document]')

 

Sep 10, 2013, 1:14 PM
586 Posts
hmmm

Shouldn't if be:

 

doc.replaceItemValue(...)

 

rather then doc.setValue()

?

Sep 10, 2013, 1:53 PM
13 Posts
hallelujah!

Of course replaceItemValue 

The problem appears to be my not setting the array.  Your code

var Field_Arr = new Array(doc.getItemValue("Status"));  solved it.

I was just setting var Field_Arr = doc.getItemValue("Status");

Many thanks for the help!
                  

 

Sep 10, 2013, 5:50 PM
453 Posts
Using The Document or DataSource

I battled with this issue, with much the same results. I posted a question to StackOverFlow with teh question which is most effecient doc.getItemValue("Field") or getComponent("Field").getValue() The answer was NEITHER

Here is a link to the answer:

http://stackoverflow.com/questions/18303862/which-is-the-most-efficient-way-to-access-the-value-of-a-control

If working with the document you must use getItemValue(), however, the most effecient way to access the backend document is by using the NotesDataSource object set to document1 by default but might be different and then use document1.getValue("Field")

working directly with the array in within the NotesDocument or the DataSource does not work in either JS or LS. I believe the most effecient method would be were document1 is the datasource

var myArray:Array = document1.getValue("SourceArray");

myArray[3] = "Some Value";

document1.setValue("SourceArray",myArray);

I have a process that cycles through a bunch (a technical term) of access to the backend document and I noticed an improvement in speed when I accessed the fields through the getValue in the datasource rather than getItemValue in the document. I am no expert in how the XPages works under the covers but the explaination in the stackoverflow make a lot of sense. I went through my code and change most of it to access the dataSource rather than the doc (got to love the search of the source code in XPages). I found a few places where I still needed to use getComponent (whcih if I read it right should actually be your last choice) or doc.getItemValue.

 

 

Jun 11, 2014, 3:12 AM
1 Posts
How about?

Hi, Robert.

As for me, I am also testing the related barcode reader these days. Do you have any ideas about it? Or any good suggestion? I am totally a green hand on this barcode reading field. Any suggestion will be appreciated. Thanks in advance.



Best regards,
Arron

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal