var errMsg = "";
if ($("[name$='comboBoxType']").val() == null){
errMsg = errMsg + '請選取需求類別';
}
if ($("[name$='comboBoxModel']").val() == null){
errMsg = errMsg + '請選取模組';
}
if ($("[name$='comboBoxSA']").val() == null){
errMsg = errMsg + '請選取SA人員';
}
if (errMsg != ""){
alert(errMsg);
return false;
}
var msg = "您選的模組為:" + $("[name$='comboBoxModel']").val() + "\n\n SA人員為:" + $("[name$='comboBoxSA']").val() +"\n\n 請確認傳送嗎?";
if (confirm(msg)==true){
return true;
}else{
return false;
}
SSJS:
//回寫 類別 模組 SA
var errMsg = "";
print("Model: " + getComponent("comboBoxModel").getValue());
print("SA: " + getComponent("comboBoxSA").getValue());
try {
print(getComponent("CurDocID").getValue());
if (getComponent("CurDocID").getValue() != ""){ //有紀錄原始文件ID
var currdoc:Notesdocument=database.getDocumentByUNID(getComponent("CurDocID").getValue());
if (currdoc == null) {
print("currdoc == null");
return false;
}
else{
var mView:NotesView = database.getView("vMISModalbyName");
if (mView == null){
print("mView == null");
return false;
}
var doc:NotesDocument = mView.getDocumentByKey(getComponent("comboBoxModel").getValue());
if (doc == null){
print("Model Doc == null");
return false;
}
currdoc.replaceItemValue("ModalID",doc.getItemValueString("ModalID"));
//currdoc.replaceItemValue("ModalName",doc.getItemValueString("ModalName"));
currdoc.replaceItemValue("SystemCategory",doc.getItemValueString("SystemCategory"));
currdoc.replaceItemValue("ModalLeader",doc.getItemValueString("ModalLeader"));
currdoc.replaceItemValue("ModalLeaderID",doc.getItemValueString("ModalLeaderID"));
currdoc.replaceItemValue("RequestType",getComponent("comboBoxType").getValue());
currdoc.replaceItemValue("ModalName",getComponent("comboBoxModel").getValue());
currdoc.replaceItemValue("SAEmpName",getComponent("comboBoxSA").getValue());
var empDB:NotesDatabase = session.getDatabase("","GroupSystem\\GroupEmpHR.nsf");
if (empDB == null){
print("empDB == null");
return false;
}
//var empView:NotesView = empDB.getView("");
var macro = "Select Form ='fmEmp' & EmpCName ='" + getComponent("comboBoxSA").getValue() + "'";
print(macro);
var empDC:NotesDocumentCollection = empDB.search(macro);
if (empDC.getCount() > 0){
var empdoc:Notesdocument = empDC.getFirstDocument();
currdoc.replaceItemValue("SAEmpCode",empdoc.getItemValueString("EmpCode"));
//currdoc.replaceItemValue("SAEmpName",empdoc.getItemValueString("EmpCName"));
currdoc.replaceItemValue("SANotesID",empdoc.getItemValueString("EmpNotesID"));
}
else{
print("empDOC == null");
return false;
}
currdoc.save();
print("currdoc.save()");
//*/ 以下為簽閱的CODE
var tmpdoc = database.createDocument(); //建立暫存文件
tmpdoc.replaceItemValue("Form","fTempSign");
print(currdoc.getItemValueString("InstanceOS"));
tmpdoc.replaceItemValue("DocNo",currdoc.getItemValueString("InstanceOS"));
tmpdoc.replaceItemValue("SignUser",@Name("[CN]",session.getEffectiveUserName()));
//tmpdoc.replaceItemValue("APPROVALALT",getComponent("ChoiceOSValue").getValue());
tmpdoc.replaceItemValue("APPROVALALT","簽閱");
//tmpdoc.replaceItemValue("SignComment",currdoc.getItemValueString("SignComment"));
tmpdoc.replaceItemValue("SignComment",getComponent("SignComment").getValue());
var agentName:String="XpageSign";
//tmpdoc.replaceItemValue("MDocUnid",getComponent("BinderDocIDOS").getValue());
tmpdoc.replaceItemValue("MDocUnid",currdoc.getItemValueString("BinderDocIDOS"));
//tmpdoc.replaceItemValue("DeleteFlag","1");
tmpdoc.save();
var NoteID:string = tmpdoc.getNoteID();
tmpdoc.recycle();
//Delete tmpdoc '此行若不加的話,後續RunOnServer 後會無法再次取得tmpdoc
var agent:NotesAgent = database.getAgent(agentName);
if(agent.runOnServer(NoteID) == 0){
var tmpdoc:NotesDocument = database.getDocumentByID(NoteID);
if (tmpdoc!=null){
if (tmpdoc.getItemValueString('IsNoWrite')== "1"){
view.postScript("alert('沒有選擇任何決定');");
}else{
//view.postScript("top.location.replace('HomePage.xsp');");
//context.redirectToHome();
}
}
else {print("tmpdoc=null");}
}else{
view.postScript("alert(agent.Name + '程式無法執行完成,請檢查,謝謝!!');");
}
}
}
//view.postScript("window.parent.$('.modal').modal('hide');");
//view.postScript("parent.location.reload();");
view.postScript("top.location.replace('HomePage.xsp');");
} catch (e) {
print("Error:" + e.toString());
getComponent("inputText1").setValue(e.toString());
//view.postScript("alert(\"" + e.toString() + "\");";
}
沒有留言:
張貼留言