Forums

Moderators: Admin, 4uTech CEO
Author Post
NetSeer
Thu Mar 04 2010, 12:10PM
Registered Member #1929
Joined: Thu Nov 23 2006, 09:42AM
Posts: 21
Hi, we are trying to implement a functionality: When the status of an Incident will be changed to Resolved, the Root Cause field needs to be Required (we are trying to make this without using SPL). We have modified the request_status_change.htmpl form to add a function to refresh the page when a new value is selected in "New Status" dropdown, this value is then saved in a HIDDEN INPUT. How can we validate that the field appears as required only if "Resolved" status is selected? I have the following lines to make the field required and appear only if the ticket is an Incident, but I do not know how to add to the condition the value from the INPUT or the javascript variable:

<PDM_IF "$args.type.sym" == "Incident" && "$prop.theForm.new_status" == "RE">
<PDM_MACRO NAME=dtlHier hdr="Root Cause" attr="rootcause" size=20 make_required=yes>
</PDM_IF>


Here the full code of the form:

<PDM_IF 0>
request_status_change.htmpl
WHEN PRESENTED:
when the app needs to update the status of a call request. When the user
clicks the 'Close Request' button from the 'Update call request' screen.
INTENT:
change the status of a call request.
VARIABLES:
object cst cst A cst object (customer) that is the logged in user.
</PDM_IF>
<html lang="en"><HEAD>
<PDM_PRAGMA RELEASE=110>
<PDM_INCLUDE FILE=styles.htmpl>
<SCRIPT LANGUAGE="JavaScript">
<PDM_IF "$env.NX_OTB_MARKET" == "itil" >
var form_title = "Status Change $args.type.sym $args.ref_num";
<PDM_ELSE>
var form_title = "Status Change Request $args.ref_num";
</PDM_IF>
</SCRIPT>
<PDM_INCLUDE FILE=std_head.htmpl>
<SCRIPT LANGUAGE="JavaScript">
edit_form = 1;
var alg_factory = "alg";
var argPersistentID = "$args.persistent_id";
var argCstID = "$cst.id";
var argRefNum = "$args.ref_num";
var argID = "$args.id";
//
<PDM_IF $env.NX_KT == "Yes">
<PDM_IF 0>
When lunching from a ticket, we want to know if the analyst has submitted a KD from ticket before,
so in case he has more knowledge to submit he could use the same KD
</PDM_IF>
var m_iNumberOfDocsSubmitted = 0;//Number of documents subbmitted from this document.
var m_lSubbmitedDocumentID = "";
<PDM_LIST FACTORY=kdlinks PREFIX=kdlinks WHERE="cr='$args.persistent_id' and link_type=3">
m_iNumberOfDocsSubmitted ++;
m_lSubbmitedDocumentID = "$kdlinks.kd";
</PDM_LIST>
</PDM_IF>
</SCRIPT>

<FORM NAME="theForm">
<INPUT NAME=new_status VALUE="">
</FORM>


<SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/arrow_button.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/check_submit.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/detail_form.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/val_type.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/kt_submit_kd.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="$CAisd/scripts/sitemods.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var resp_sym = new Array();
var resp_ids = new Array();
resp_sym[0] = "";
resp_ids[0] = "";
resp_field="SET.alg.description";
resp_persid='$args.persistent_id';

<PDM_IF "$args.type" == "R" || "$args.type" == "">
<PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND cr_flag=1">
resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
resp_ids[resp_ids.length] = '$list.id';
</PDM_LIST>
<PDM_ELIF "$args.type" == "I">
<PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND in_flag=1">
resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
resp_ids[resp_ids.length] = '$list.id';
</PDM_LIST>
<PDM_ELIF "$args.type" == "P">
<PDM_LIST ESC_STYLE=JS2 prefix=list factory=response where="delete_flag=0 AND (response_owner IS NULL or response_owner = U'$cst.id') AND pr_flag=1">
resp_sym[resp_sym.length] = decodeURIComponent('$list.sym');
resp_ids[resp_ids.length] = '$list.id';
</PDM_LIST>
</PDM_IF>

// Refresh screen if value selected/changed on the "New Status" dropdown in the initial screen.
//Based on the function from detail_macro.htmpl
function refresh_screen_without_saving(select_obj, sel_stat) {
alert("Page refresh function: "+sel_stat);
document.theForm.new_status.value = sel_stat;
var f = window.document.forms["main_form"];
f.REFRESH_AND_STAY_EDIT.value="1";
f.MACRO_TYPE.value = select_obj.value;
<PDM_IF 0>
Calling detail_save() to submit everything to freeaccess. Note in this case I am restrict the
save from happening if REFRESH_AND_STAY_EDIT.value is set to 1 in the freeaccess code, It just refreshes the screen.
Note also that it hold all the values in the fields on the form prior to the refresh
// The variable KEEP.BHVNOTIFY_MANY_SELECTED is also set to 1 in freeaccess
</PDM_IF>
pdm_submit('main_form','UPDATE',void(0),true);
}

//To be called from the dtltextbox macro
function create_submit_knowledge_btn()
{
docWriteln("<TH>");
ImgBtnCreate("btn004", "Submit_Knowledge", 'submit_knowledge()', true, 0);
docWriteln("</TH>");
}
function submit_knowledge()
{
// If no KD was created from this ticket before, we'll just create a new KD
// If 1 KD was created from this ticket before, we'll ask the user if he wants to review it or create a new one.
// If more than 1 KDs were submitted from this ticket we'll ask the user if to create a new one and adivise him to look at the solutions tab
var bCreateNewKD = true;//DEFAULT VALUE FOR m_iNumberOfDocsSubmitted = 0 case
if(ahdtop.cfgNX_KT == "Yes")
{
if (m_iNumberOfDocsSubmitted == 1)
{
var sMsgText = msgtext("A_Knowledge_Document_was_already_submitted_from_this_request");
<PDM_IF "$env.NX_OTB_MARKET" == "itil">
<PDM_IF "$args.type" == "I">
sMsgText = msgtext("A_Knowledge_Document_was_already_submitted_from_this_incident");
<PDM_ELIF "$args.type" == "P">
sMsgText = msgtext("A_Knowledge_Document_was_already_submitted_from_this_problem");
</PDM_IF>
</PDM_IF>
if (confirm(sMsgText))
{
bCreateNewKD = true;
}
else
{
var features="directories=no"+
",location=no"+
",height=" + popupHeight(LARGE_POPUP) +
",width=" + popupWidth(LARGE_POPUP)+
",status=no";
//
bCreateNewKD = false;
var lKDPersID = "KD:" + m_lSubbmitedDocumentID;
popup_window(lKDPersID,'SHOW_DETAIL', 0, 0, features, 'PERSID='+lKDPersID,'+RELOAD_WIN=0');
return;
}
}
else if (m_iNumberOfDocsSubmitted > 1)
{
var sMsgText = msgtext("Several_Knowledge_Documents_have_been_submitted_from_this_request");
<PDM_IF "$env.NX_OTB_MARKET" == "itil">
<PDM_IF "$args.type" == "I">
sMsgText = msgtext("Several_Knowledge_Documents_have_been_submitted_from_this_incident");
<PDM_ELIF "$args.type" == "P">
sMsgText = msgtext("Several_Knowledge_Documents_have_been_submitted_from_this_problem");
</PDM_IF>
</PDM_IF>
if (!confirm(sMsgText))
{
bCreateNewKD = false;
}
}
}
//
if (!bCreateNewKD)
{
return;
}
var form_vars = new Array();
//If the ticket detail page is opened and in edit mode, use the latest values to create the knowledge
form_vars["SD_OBJECT_PERSID"] = "$args.persistent_id";
if (null != top.opener && !top.opener.closed && typeof top.opener._dtl != "undefined" && top.opener._dtl.edit)
{
var func = top.opener.detailValueOf;
form_vars["PROBLEM"] = func("SET.description");
form_vars["SUMMARY"] = func("SET.summary");
form_vars["SD_ASSET_ID"] = func("SET.affected_resource");
form_vars["SD_SEVERITY_ID"]= func("SET.severity");
form_vars["SD_IMPACT_ID"] = func("SET.impact");
form_vars["SD_URGENCY_ID"] = func("SET.urgency");
form_vars["SD_PRIORITY_ID"] = func("SET.priority");
form_vars["SD_CATEGORY"] = func("KEY.category");
form_vars["SD_ROOTCAUSE_ID"] = func("SET.rootcause");
<PDM_IF && "itil" == "$env.NX_OTB_MARKET" && "$args.type" == "I">
form_vars["SD_PROBLEM"] = func("SET.problem");
<PDM_ELIF && "itil" == "$env.NX_OTB_MARKET" && "$args.type" == "P">
form_vars["SD_PROBLEM"] = "$args.persistent_id";
<PDM_ELSE>
form_vars["SD_PROBLEM"] = "";
</PDM_IF>
}
else
{
form_vars["SUMMARY"] = <PDM_FMT ESC_STYLE=C>"$args.summary"</PDM_FMT>;
form_vars["PROBLEM"] = <PDM_FMT ESC_STYLE=C>"$args.description"</PDM_FMT>;
form_vars["SD_ASSET_ID"]="$args.affected_resource";
form_vars["SD_SEVERITY_ID"]="$args.severity";
form_vars["SD_IMPACT_ID"]="$args.impact";
form_vars["SD_URGENCY_ID"]="$args.urgency";
form_vars["SD_PRIORITY_ID"]="$args.priority";
form_vars["SD_CATEGORY"]= <PDM_FMT ESC_STYLE=C>"$args.category.COMMON_NAME"</PDM_FMT>;
form_vars["SD_ROOTCAUSE_ID"]="$args.rootcause";
<PDM_IF && "itil" == "$env.NX_OTB_MARKET" && "$args.type" == "I">
form_vars["SD_PROBLEM"] = "$args.problem";
<PDM_ELIF && "itil" == "$env.NX_OTB_MARKET" && "$args.type" == "P">
form_vars["SD_PROBLEM"] = "$args.persistent_id";
<PDM_ELSE>
form_vars["SD_PROBLEM"] = "";
</PDM_IF>
}
form_vars["RESOLUTION"] = detailValueOf("SET.alg.description");
ahdtop.SetSolutionText(form_vars["RESOLUTION"],form_vars["SD_OBJECT_PERSID"]);
ahdtop.SetProblemText(form_vars["PROBLEM"],form_vars["SD_OBJECT_PERSID"]);
<PDM_IF "$prop.form_name_3" == "ro">
popup_window(
<PDM_ELSE>
var oWin = window;
if (!ahdtop.cstReducePopups && null != top.opener)
{
var oWin = top.opener;
}
oWin.popup_window(
</PDM_IF>
"", "CREATE_NEW", popupWidth(LARGE_POPUP), popupHeight(MEDIUM_POPUP),
"", "FACTORY=KD",
addSubmitKnowledgePreSet(form_vars, "SD_OBJECT_PERSID", true),
addSubmitKnowledgePreSet(form_vars, "SUMMARY", true),
addSubmitKnowledgePreSet(form_vars, "SD_CATEGORY", true),
addSubmitKnowledgePreSet(form_vars, "SD_ASSET_ID", true),
addSubmitKnowledgePreSet(form_vars, "SD_ROOTCAUSE_ID", true),
addSubmitKnowledgePreSet(form_vars, "SD_SEVERITY_ID", true),
addSubmitKnowledgePreSet(form_vars, "SD_PRIORITY_ID", true),
addSubmitKnowledgePreSet(form_vars, "SD_URGENCY_ID", true),
addSubmitKnowledgePreSet(form_vars, "SD_IMPACT_ID", true)
<PDM_IF "$env.NX_OTB_MARKET" == "itil">
, addSubmitKnowledgePreSet(form_vars, "SD_PROBLEM", true)
</PDM_IF>
);
}
</SCRIPT>

</HEAD>
<BODY onload="load_from_scratchpad('0')" onUnload="unload_check()" class=editform>
<PDM_INCLUDE FILE=std_body.htmpl filename="">
<CENTER>

<SCRIPT LANGUAGE="JavaScript">
ahdframeset.top_splash.next_persid = "$args.persistent_id";
<PDM_MACRO NAME=dtlForm factory=cr>
<PDM_MACRO NAME=dtlStart>

docWriteln("<INPUT TYPE=hidden NAME=HTMPL VALUE='show_main_detail.htmpl'>");
docWriteln("<INPUT TYPE=hidden NAME=KEEP.IsModified VALUE='1'>");

if (_dtl && _dtl.next_persid == "")
_dtl.next_persid = 'show_main_detail.htmpl';

<PDM_MACRO NAME=dtlStartRow>
<PDM_IF "$env.NX_OTB_MARKET" == "itil" >
<PDM_MACRO NAME=dtlReadonly hdr="$args.type.sym Number" attr="ref_num">
<PDM_MACRO NAME=dtlReadonly hdr="$args.type.sym Summary" attr="summary" colspan=2>
<PDM_MACRO NAME=dtlStartRow>
<PDM_MACRO NAME=dtlReadonly hdr="Current Status" attr="status">
<PDM_IF "$args.type" == "I">
<PDM_IF "$args.status" == "RE">
<PDM_MACRO NAME=dtlDropdown hdr="New Status" attr="status" lookup=no factory=crs_in evt="onBlur=\\\"detailSyncEditForms(this)\\\" onChange=\\\"refresh_screen_without_saving(this, this.value)\\\"">
<PDM_ELSE>
<PDM_MACRO NAME=dtlDropdown hdr="New Status" attr="status" lookup=no factory=crs_in evt="onBlur=\\\"detailSyncEditForms(this)\\\" onChange=\\\"refresh_screen_without_saving(this, this.value)\\\"" whereclause="code != 'CL'">
</PDM_IF>
<PDM_ELIF "$args.type" == "P">
<PDM_MACRO NAME=dtlDropdown hdr="New Status" attr="status" lookup=no factory=crs_pr evt="onBlur=\\\"detailSyncEditForms(this)\\\"">
<PDM_ELSE>
<PDM_IF "$args.status" == "RE">
<PDM_MACRO NAME=dtlDropdown hdr="New Status" attr="status" lookup=no factory=crs_cr evt="onBlur=\\\"detailSyncEditForms(this)\\\"">
<PDM_ELSE>
<PDM_MACRO NAME=dtlDropdown hdr="New Status" attr="status" lookup=no factory=crs_cr evt="onBlur=\\\"detailSyncEditForms(this)\\\"" whereclause="code != 'CL'">
</PDM_IF>
</PDM_IF>

<PDM_ELSE>
<PDM_MACRO NAME=dtlReadonly hdr="Request Number" attr="ref_num">
<PDM_MACRO NAME=dtlReadonly hdr="Request Summary" attr="summary" colspan=3>
<PDM_MACRO NAME=dtlStartRow>
<PDM_MACRO NAME=dtlReadonly hdr="Current Status" attr="status">
<PDM_MACRO NAME=dtlDropdown hdr="New Status" attr="status" evt="onBlur=\\\"detailSyncEditForms(this)\\\"">
</PDM_IF>
<PDM_MACRO NAME=dtlLookup hdr="Configuration Item" attr="affected_resource" size=20>
<PDM_IF "$args.type.sym" == "Incident" && "$prop.theForm.new_status" == "RE">
<PDM_MACRO NAME=dtlHier hdr="Root Cause" attr="rootcause" size=20 make_required=yes>
</PDM_IF>
<PDM_MACRO NAME=dtlStartRow>
<PDM_MACRO NAME=dtlTextbox hdr="Time Spent" attr="alg.time_spent" evt="onBlur='validate_duration_ts(this)'" make_required=yes>
<PDM_MACRO NAME=dtlCheckbox hdr="Operative?" attr="zoperflag">
<PDM_MACRO NAME=dtlDate hdr="Scheduled for..." attr="zScheduleDate" size=20>
detailSetValidate("Time Spent", $args.alg.REQUIRED_time_spent, 100);
<PDM_MACRO NAME=dtlDate hdr="Date of Activity" attr="alg.time_stamp">
<PDM_MACRO NAME=dtlDateReadonly hdr="Time Stamp" attr="alg.system_time">
<PDM_IF "$prop.view_internal" == "1">
<PDM_MACRO NAME=dtlCheckbox hdr="Internal?" attr="alg.internal">
</PDM_IF>
<PDM_MACRO NAME=dtlStartRow>
<PDM_IF "$env.NX_KT" == "Yes">
<PDM_MACRO NAME=dtlTextbox hdr="User Description" attr="alg.description" size=80 colspan=4 rows=8 spellchk=yes JSButton="create_submit_knowledge_btn()">
</PDM_ELSE>
<PDM_MACRO NAME=dtlTextbox hdr="User Description" attr="alg.description" size=80 colspan=4 rows=8 spellchk=yes>
</PDM_IF>
detailSetValidate("User Description", $args.alg.REQUIRED_description,
$args.alg.LENGTH_description);

<PDM_IF "$args.sla_violation" > "0">
<PDM_MACRO NAME=dtlStartExpRow form_name="detail_cr" label="SLA Expiration Reason" exp_rows="1,2" colspan=4>
<PDM_MACRO NAME=dtlStartRow>
<PDM_MACRO NAME=dtlTextbox hdr="SLA Expiration Reason" attr="zslaexptext" size=60 colspan=3 rows=4 make_required=yes>
<PDM_MACRO NAME=dtlDropdown hdr="SLA Expiration Reason Code" attr="zslaexpcode" size=20 whereclause="id != 40001" make_required=yes>
</PDM_IF>


if (resp_ids.length > 1)
{
<PDM_MACRO NAME=dtlStartRow>
detailRowHdr("Personalized Response",1,0);
docWriteln('<TR><TD ALIGN=LEFT>');
_dtl.eventHandler = "onBlur='add_response(selectedIndex)' onChange='reset_resp_on_blur_flag()'";
docWriteln('<SELECT' + detailNextID(true) + '>');
for (i = 0; i < resp_ids.length; i++)
{
docWrite('<OPTION VALUE="' + resp_ids[i] + '" ');
docWriteln('>' + resp_sym[i] +'</OPTION>');
}
docWriteln('</SELECT></TD></TR>');
}

</SCRIPT>
<PDM_MACRO NAME=dtlEnd>
</PDM_FORM>
</CENTER>
<PDM_INCLUDE FILE=std_footer.htmpl>
</BODY>
</HTML>
<PDM_IF 0>
@(#)$Id: request_status_change.htmpl FWr1.7 2008/9/29 21:1:43 hu$ho01 Exp $
</PDM_IF>
<PDM_WSP>


Thank you in advance for all your help and cooperation.

Back to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

This site is not affiliated with CA. All trademarks are © their respective owners. All other content is © HelpDeskUsers.com and 4uTechnologies, Inc.
4uTechnologies, Inc. reserves the right to content contained within this site.
{THEMEDISCLAIMER}