In Notes/Domino Form (=Design) and Document are different and (more or less) independent things.
Whenever you create a document, it takes the form AT THAT MOMENT and creates items for all fields that are on the form when the document is created.
The same happens when opening an existing document: It looks for the form and displays its data in the way it is designed there. New items for new fields are added on demand.
BUT: They are not SAVED to the document before you explicitly do that.
This process is pure frontend.
Notes NEVER changes existing documents automatically just because you changed something in the corresponding form (aka create a new Field "Status" with the value "QUEUED".
That is why your script does not get the item (unless you open the document and the field in the form becomes an item).
There are different ways to update your documents with the changes you made to the form.
The first one is: Open all documents in frontend and save them... But that is very time consuming.
You can update the documents using a Formula agent.
Just select "None" as Target (this is important as we need to use @Commands and they do not work with any target) and put in the Formula:
@Command([ToolsRefreshSelectedDocs])
then select the documents to refresh and run the agent on them.
You can also use a LotusScript Agent. This one needs to run on selected documents:
Dim ses as New NotesSession
Dim db as NotesDatabase
Dim dc as NotesDocumentCollection
Dim doc as NotesDocument
Set db = ses.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument()
While not doc is Nothing
Call doc.ComputeWithForm( False, False )
Call doc.Save( True, true, True )
Set doc = dc.GetNextDocument( doc )
Wend
Of course you can -instead of just refreshing all documents- add that code to your existing code:
Set nvwQueuedOrderLines = dbCurrent.Getview("QueuedOrderLines")
Dim docOrderRegel As NotesDocument
Set docOrderRegel = nvwQueuedOrderLines.GetFirstDocument
If not docOrderRegel.HasItem( "Status" ) then
Call docOrderRegel.ComputeWithForm( False, False )
End If
If docOrderRegel.Status(0) = "QUEUED" Then