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



Oct 28, 2013, 5:27 AM
5 Posts

AppendToTextList alternative on xPages

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 3

Hi,

I hope you guys doing good. I have requirement of usage of LotusScript appendtotextlist functionality's alternative in xpage using Sever Side JavaScript e.g. I have field name X for selection of users from domino directory and i want to append selected user in a multivlaue field after checking that this user exists or not. How can I do this using server side javascript. I heard to create an array and add user into array and than  push array on UI field. If possible please share sample code.

Your prompt help in this regard will be highly appreciated.

Thanks,

Jeni

 

 

 

Oct 28, 2013, 11:43 AM
54 Posts
appendToTextList

Alternative you can use appendToTextLIst form Java.

Sample code can be wiewed in designer help

Oct 28, 2013, 11:46 AM
586 Posts
hmmm

I've been working with Multi-Value fields recently - however I've been working in Java and not SSJS.  hopefully I'll have notesIn9 show on this soon...  I  know you want SSJS but keep in mind that SSJS can use Java objects..

Now...  in my Java class I'm doing something like this to LOAD in Multi-values..rgrregreg

categoryAdmins = new Vector<String>((List<String>)lookupDoc.getItemValue("categoryAdmin"));

It looks scary... even to me.. but what I believe this is doing is reading the values from the field and then putting them into a Vector.  A Vector is like an Array in Lotusscript.  It's not used much in the Java world anymore but that's what the Domino Objects use.

To save the values back to the doc I'm doing this:

lookupDoc.replaceItemValue("categoryAdmins", new Vector<String>((List<String>)categoryAdmins));

So it seems that if you have a Vector you can save that directly to a Document field like you can an array.  And unlike a LotusScript List that must be converted back to an array.

In SSJS you should be able to create a vector object and assign values to it.  I'm GUESSING something like:

var myVector:java.util.Vector = new java.util.Vector();

Then there should be methods for add..  remove...  even contains I THINK.

then when you go to save it... try just saving the vector back to the document:

meDoc.replaceItemValue("myField", myVector);

And see if that works.  I don't have first hand experience of this... but I THINK it'll work.

I did a show on using Java Objects for NotesIn9.  I didn't use Vector's...  I used HashMaps and ArrayLists I believe.. http://notesin9.com/index.php/2011/07/11/notesin9-ee-009-using-java-hashmaps-and-treemaps-with-xpages/

That MIGHT be worth a look simply because of working with the Java object inside SSJS.

 

Best of Luck!!!

 

Dave

 

 

 

Oct 30, 2013, 10:17 AM
5 Posts
SSJS Vector

Hi!

You can use Vector to loop through values and also append/remove entries.

Example 1: Remove "John Doe" from multivalue field called Persons:

var nametoremove ="John Doe";

var persons= doc.getItemValue("Persons"); 

if (persons.contains(nametoremove)) {

persons.remove(nametoremove);

doc.replaceItemValue("Persons", persons);

}

Example 2: Merge 2 multivalue fields by using Vector

var newpersons:java.util.Vector = new java.util.Vector();

var persons1 = doc.getItemValue("Persons1");

var persons2 = doc.getItemValue("Persons2");

var iterator = persons1.iterator();
while (iterator.hasNext()) 
{
var itemvalue = iterator.next();
if (newpersons.contains(itemvalue)) 
{
newpersons.add(itemvalue);
}
}

doc.replaceItemValue("AllPersons", newpersons);

 

Hope this helps!


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