Notes API doesn't return updated values

Hi all,

I have a problem getting document property in Lotus Notes. I use Java and created a huge plugin.

I get the email field of the email document with this code:

 /** @see com.ibm.lotuslabs.context.service.document.IDocumentContextListenerm#selectionChanged(IWorkbenchPart

 *      part, DocumentSelection context)

 */

public void selectionChanged(IWorkbenchPart part,

        DocumentSelection selection)

{

{

    selectedEmail = null;        

    type = -1;



    final IDocumentContext[] array = (selection == null) ? null : selection

            .getItems(); // copy 'selection' into an array to pass to the UIJob

    final UIJob show = new UIJob("Update toolbar")

    {

        public IStatus runInUIThread(IProgressMonitor monitor)

        {

            try

            {

                if (array != null && array.length == 1 && array[0] != null && array[0].getURI() != null)

                {

                    String uri = array[0].getURI().toString();

                    if(0 != uri.compareTo(""))

                    {	

                        Document doc = Applications.getDocument(uri);



                        if (doc != null)

                        {

                            String docForm = doc

                                    .getItemValueString("Form");

                        					String neededField = doc.getItemValueString("SendTo);

                            	}

}

But when I update the document’s email field (“SendTo” field), Notes still returns the old field in neededField! And no way to get the updated value. Maybe this is a wrong thread to work in or a wrong way to get the document.

Any help will be great.

Thanks.

Gor

Subject: Can you post full code?

Could you please post full code what you are trying to do. The information is insufficient here.

Subject: The plugin code

Thanks for the response, hopefully we’ll solve this.

package com.plugin.myplugin;

public class PluginContribution extends ContributionItem implements IDocumentContextListener,

													ISContributionItem

{

 /*

 * (non-Javadoc)

 * 

 * implementation of PluginContribution begins here

 */



/**

 * The default constructor

 */

public PluginContribution()

{



}



 /*

 * (non-Javadoc)

 * 

 * @see com.ibm.rcp.jface.action.ISContributionItem#fill(com.ibm.rcp.swt.swidgets.SCoolBar,

 *      int)

 */

public void fill(SCoolBar arg0, int arg1)

{

	// register for context changed events

	contextService = DocumentContextService.getDefault();

	contextService.addSelectionListener(this);



	// force an update now

	selectionChanged(contextService.getWorkbenchPart(), contextService

			.getDocumentSelection());

}



/*

 * (non-Javadoc)

 * 

 * @see ISContributionItem#dispose()

 */

public void dispose()

{

    if (contextService != null)

        contextService.removeListener(this);



    super.dispose();

}



/*

 * (non-Javadoc)

 * 

 * @see com.ibm.lotuslabs.context.service.document.IDocumentContextListenerm#selectionChanged(IWorkbenchPart

 *      part, DocumentSelection context)

 */

public void selectionChanged(IWorkbenchPart part,

        DocumentSelection selection)

{

    String neededField = "";



    final IDocumentContext[] array = (selection == null) ? null : selection

            .getItems(); // copy 'selection' into an array to pass to the

    // UIJob

    final UIJob show = new UIJob("Update toolbar")

    {

        public IStatus runInUIThread(IProgressMonitor monitor)

        {

            try

            {

                if (array != null && array.length == 1 && array[0] != null && array[0].getURI() != null)

                {

                    String uri = array[0].getURI().toString();

                    if(0 != uri.compareTo(""))

                    {	

                        Document doc = Applications.getDocument(uri);



                        if (doc != null)

                        {

                            String docForm = doc

                                    .getItemValueString("Form");



                            if (docForm != null) {

                            	// get email item

                            	if (0 == docForm

                                        .compareTo("Memo"))

                                {

                                    neededField = doc

                                            .getItemValueString("SendTo");

                                }

                            }

                        }

                	}

                }

            } catch (Throwable t)

            {

				t.prinstStack();

            }

			

			return Status.OK_STATUS;

        }

    };



    show.schedule();

}



// context service to hold currently selected document

private DocumentContextService contextService;

}

Thanks.

Gor