Examples: setValueCustomDataBytes method

This agent sets an item in the current document to the value of a byte array.

import lotus.domino.*;
import java.io.*;

public class JavaAgent extends AgentBase {

  public void NotesMain() {

    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();

      // (Your code goes here) 
      
      // Create byte array
      byte[] bytes = new byte[10];
      for (int i = 0; i < 10; i++)
        bytes[i] = (byte) (i + 65);

      // Store custom data as item
      Document doc = agentContext.getDocumentContext();
      if (doc.hasItem("TenBytesItem")) {
        Item item = doc.getFirstItem("TenBytesItem");
        if (item.getType() == Item.USERDATA) {
          item.setValueCustomDataBytes
          ("TenBytesType", bytes);
          doc.save();
        }
        else
          System.out.println("Not user data");
      }
      else
        System.out.println("No item TenBytesItem in document");

    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}