Search This Blog

Saturday, July 26, 2014

NotesItem.Type = 256 causes "Variant does not contain a container"

Hi

Today I had to convert a collection of NotesDocuments for some external system.
For one particular document I received an error "Variant does not contain a container".
When I checked it in Domino Debugger I saw that error happened at the line contained following code:

......
if cstr(doc.getitemvalue("itemname")(0)) <> "" then '<---error here
       .....
end if
.....

Code looked pretty simple and completely correct and though this error message was familiar for me I couldn't get why it happened there. I understood what was wrong only after I found that particular document and checked what was in that item.


The item had 'Error' type.


The item was created based on computed form field with formula like @GetDocField("_empty_universalid_"; "itemname"), however it does not matter what formulas was because there could be hundreds of cases which may produce similar result. So, this is another one example, why it is so important to use @IfError() or @if(@isError()).

For my conversion task I just used comparison, like

......
set item = doc.getfirstitem("itemname")
if not item is nothing then
       if item.type <> 256 then <--workaround
              if item.text <> "" then
                     .....
              end if
       end if
end if
.....

to skip such items.

No comments:

Post a Comment