2016-04-05 18 views
0

我已經在SSJS庫中創建了一個函數。因爲我在多個XPage中使用它。NotesXSPDocument和NotesDocument

當我在按鈕後面調用該函數時,我看不到該字段中的值 如果我打印出來,我可以在管理控制檯中看到該值,但無法在表單中看到它即使我獲取了完全刷新的頁面。

其實我的另一個問題是..是否有可能比較notesXSPDocument和NotesDocument。也許有人會說那最好的辦法是什麼?

function deneme(document1:NotesXSPDocument,otherDocfromOtherDatabase:NotesDocument) 
      { 
       //do staff here 
       if (document1.getItemValueString("field1")==otherDocfromOtherDatabase.getItemValueString("field2")) 
    { //do some staff here... 
       document1.replaceItemValue("fieldName","FieldValue");} 
      } 
+0

http://stackoverflow.com/search?q=compare+strings+java –

回答

1

您可以比較來自Document和XSPDocument的項目值,只需要注意您正在比較的類型。

在您的代碼中,您將使用==運算符比較2個javascript字符串。 代碼似乎沒問題,只記得在更改後保存document1,並檢查這些項目是否具有某些價值。

var valueFromXspDoc = document1.getItemValueString("field1"); 
var valueFromDoc = otherDocfromOtherDatabase.getItemValueString("field2"); 

if (valueFromXspDoc && valueFromDoc && (valueFromXspDoc === valueFromDoc)) { 
    // stuff here... 
    document1.replaceItemValue("fieldName","FieldValue"); 
    document1.save(); 
} 
1

不要將它與==符號進行比較。更好的方法是document1.getItemValueString(「field1」)。equals(otherDocfromOtherDatabase.getItemValueString(「field2」))

相關問題