0

I have a process on the beforePageLoads that executes if it is a newDocument. It grabs a profile docuemnt that contains a number of fields that I need to copy into the XPage that is being loaded. I use the following code:

var iCol:Array = pDoc.getItems()

    for(var i=0; i<iCol.length; i++){
        var item:NotesItem = iCol[i];
        var iName:String = item.getName();
        if (@Left(iName, 2) == "AC" ){
            iCol[i].copyItemToDocument(doc,"");
        }
        item.recycle()
    } // for loop

where pDoc is the profile document and doc is backend document obtained by var doc = document1.getDocument(). I can then use the copyItemTODocument method and this works real well except I need to refresh the dataSource from the backend document. I can do this from a button and do a partial refresh but that is not an option in a production situation. I have tried various refresh options (suggested in this forum) but none of them get the job done. I can copy the values from the profile document fields to a filed in the datasource but this gets really messy because of data types. I believe my refresh problem is related to updating the doc not document1 in my code. Is there a way to refresh document1 from the backend document?

Bill F
  • 2,057
  • 3
  • 18
  • 39
  • What refresh options have you tried? – Per Henrik Lausten Sep 26 '13 at 05:10
  • You should copy only needed items - do not copy all items of profile document. You can go for blacklist or whitelist strategy. – Frantisek Kossuth Sep 26 '13 at 07:37
  • @FrantisekKossuth that is what I am doing all of the fields starting with AC are copied. – Bill F Sep 27 '13 at 20:46
  • @PerHenrikLausten I have tried using all of the options given in this thread: http://stackoverflow.com/questions/18925970/call-partialrefreshget-from-ssjs-using-view-postscript none of which get teh result I need. The only thing that works so far is to do a partial refresh from the onClick event of a button, but that is not really a workable solution for a real world page. – Bill F Sep 27 '13 at 20:50

1 Answers1

0

Does this help ..

http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=84329CA285163DDF852578CB00669143

it hints at two things whcih may be osf use : "It appears that during the initial PageLoad events the existing data is transferred from the NotesDocument to the NotesXspDocument. Only those fields bound to the NotesXspDocument (on XPage or CC) are transferred. "

and in the comments section:

"Another way of getting data from the XspDocument to the NotesDocument without a save, is to use document1.getDocument(true) which basically re-syncs the data between the two objects.

I don't have time to experiment I'm afraid but it looks like this is along the right lines, espcially the second part. Doug

user2808054
  • 1,376
  • 1
  • 11
  • 19