调用方法发生异常 NotesDatabase.getDocumentByUNID(null) null

Exception occurred calling method NotesDatabase.getDocumentByUNID(null) null

我不明白为什么使用以下代码会出现上述错误:

value1 = sessionScope.get("selectedPicture");
if (value1 != "empty"){
    var db:NotesDatabase = session.getDatabase(database.getServer(), "product\picture.nsf");
    if (db != null) {
        var IDtoChange = toString("7D59468E241AC271C1257D5000417E46") ;
        if (IDtoChange = null){
           return
        }
        try {
             doc = db.getDocumentByUNID(IDtoChange);
             doc.replaceItemValue( 'picWeb', "true" );
             doc.save( true, false );
             sessionScope.put("selectedUnid","");
        } catch(e) {
             sessionScope.put("error",(e.toString()));
             context.redirectToPage("errorPage.xsp");
       }
   }
}

当我替换行 doc = db.getDocumentByUNID(IDtoChange);使用 doc = db.getDocumentByUNID("7D59468E241AC271C1257D5000417E46");一切正常

怎么了? (在我的真实代码中,id 当然不是硬编码的)

第六行应该是if (IDtoChange == null){而不是if (IDtoChange = null){。单个 = 看起来是在分配值而不是比较 ==