【问题标题】:Exception occurred calling method NotesDatabase.getDocumentByUNID(null) null调用方法 NotesDatabase.getDocumentByUNID(null) 发生异常 null
【发布时间】:2015-01-31 10:25:13
【问题描述】:

我不明白为什么我使用以下代码收到上述错误:

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); with doc = db.getDocumentByUNID("7D59468E241AC271C1257D5000417E46");一切正常

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

【问题讨论】:

    标签: xpages xpages-ssjs


    【解决方案1】:

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

    【讨论】:

    • Rob,当我按照您的建议更改代码时,我收到另一条错误消息:调用方法 NotesDatabase.getDocumentByUNID(string) null
    • 尝试将var IDtoChange = toString("7D59468E241AC271C1257D5000417E46") ;更改为var IDtoChange = "7D59468E241AC271C1257D5000417E46" ;
    • Rob,它是这样工作的。奇怪,我以为它必须是一个字符串,所以我放了“toString”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-28
    • 1970-01-01
    相关资源
    最近更新 更多