The PTC Community will be on read only status starting March 23rd in preparation for moving our platform to a new provider. Read more here
在 Windchill 中驳回工作流任务时,需要验证 "备注" 字段不为空;通过工作流任务时,不验证 "备注" 字段是否为空;怎么配置
Solved! Go to Solution.
Hi @QS_10834211,
Did you follow Step 3 in article CS150969?
If you have done so, please try adding some alerts in the JavaScript function and check where it is breaking.
Hi @QS_10834211,
Refer the following articles to implement the same.
https://www.ptc.com/en/support/article/CS35488?source=search
https://www.ptc.com/en/support/article/CS150969?source=search
<objecttype name="work" class="wt.workflow.work.WorkItem">
<action name="complete" enabledwhensuspended="true" ajax="page">
<command class="ext.workitem.work.CustNmWorkItemCommands"
method="complete" onClick="customWorkitemCompleteOnClick()" />
</action>
</objecttype><script type="text/javascript" language="javascript" charset="utf-8">
function customWorkitemCompleteOnClick(){
return customWorkitemCompleteValidator();
}
function customGetWorkitemComment(){
var inputs = document.getElementsByTagName("input");
for(var i in inputs){
var input = inputs[i];
if(input.type=='radio'){
if(input.checked){
console.log(input.value);
if(input.value=='\u9a73\u56de'){//if Chinese is used, it will be garbled
if( (document.getElementById("workitem_comment").value == "") || (document.getElementById("workitem_comment").length == 0)){
return false;
}else{
return true;
}
}
}
}
}
return true;
}
function customWorkitemCompleteValidator(){
var result = true; // if returned result is false, the task form will stay opened
var comment = customGetWorkitemComment();
result=comment;
if(result){
result = EnableTextBox(); // call ootb onClick handler
}else{
alert("\u5ba1\u6279\u610f\u89c1\u4e0d\u80fd\u4e3a\u7a7a");
}
return result;
}
</script>javascript代码放到netmarkets/jsp/util/begin_custom.jspf中,然后要修改完成任务的action,对于中文提示,要用unicode编码下才可以正常显示。
Hi Professor
代码已经放到netmarkets/jsp/util/begin_custom.jspf中
代码:
function customWorkitemCompleteOnClick(){ return customWorkitemCompleteValidator(); } function customGetWorkitemComment(){ var inputs = document.getElementsByTagName("input"); for(var i in inputs){ var input = inputs[i]; if(input.type=='radio'){ if(input.checked){ console.log(input.value); if(input.value=='驳回'){//if Chinese is used, it will be garbled if( (document.getElementById("workitem_comment").value == "") || (document.getElementById("workitem_comment").length == 0)){ return false; }else{ return true; } } } } } return true; } function customWorkitemCompleteValidator(){ var result = true; // if returned result is false, the task form will stay opened var comment = customGetWorkitemComment(); result=comment; if(result){ result = EnableTextBox(); // call ootb onClick handler }else{ alert("审批意见不能为空"); } return result; }
但是没有生效,不知道什么原因;
你说的“要修改完成任务的action”,是怎么改?
Qihao.Shang
PLM Engineer
Hi @QS_10834211,
Have you added the following entry to custom-actions.xml?
<objecttype name="work" class="wt.workflow.work.WorkItem">
<action name="complete" enabledwhensuspended="true" ajax="page">
<command class="com.ptc.netmarkets.work.NmWorkItemCommands" method="complete" onClick="validateComments()"/>
</action>
</objecttype>
I have already added this code to the custom-actions.xml, However, the workflow did not check the workitem_comment when it selected “Reject.”
my custom-actions.xml: ()
<objecttype name="work" class="wt.workflow.work.WorkItem">
<action name="complete" enabledwhensuspended="true" ajax="page">
<command class="com.ptc.netmarkets.work.NmWorkItemCommands" method="complete" onClick="validateComments()"/>
</action>
</objecttype>
my begin_custom.jspf:
Hi @QS_10834211,
Did you follow Step 3 in article CS150969?
If you have done so, please try adding some alerts in the JavaScript function and check where it is breaking.
OK.thanks
