Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need logic to make comments mandatory when state is changed from closed to Resolved

Bhavya11
Kilo Patron
Kilo Patron

Hi 

i have requirement from  customer they want ability make closed incident back to resolve state and need to make Additional comment  mandatory.

 

i tired way to achieve this but   Additional comment is not visible to ITIL user once the incident is closed so if i make the Additional comment mandatory via ui action from change the state from Close to Resolve its not working.

i created read ACL to provide the  access to see once the state change  is Close but it didn't work as expected.

 

Could you please anyone help on this.  

 

Thanks in Advance

 

Regards

BK 

1 ACCEPTED SOLUTION

Bhavya11
Kilo Patron
Kilo Patron

Hi All 

thanks for reply.

 

i have able to found the solution for make comments mandatory when state is changed from closed to Resolved

 

i have created ui action 

 

Name : Reopen incident 

Condition: gs.hasRole("itil") && current.state==7
Onclick: commentsDialog();
Action name: reoepn_inc_close
Script:

function commentsDialog() {
var message =g_form.getValue("short_description");
var dialog = new GlideDialogWindow("commmentpage"); 
dialog.setTitle("Add Comment"); 

dialog.setSize(750,300);
dialog.setPreference("sysparm_message", message); 
dialog.render(); 
}

Create the ui page;

Name : commmentpage

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:ui_form>
<input type="hidden" id="jvar_answer" name="jvar_answer" value=""/>

<input type="hidden" id="contentvalue" name="contentvalue"/>
<input type="hidden" name="cancel_or_submit" id="cancel_or_submit" value=""/>

<textarea id="content" name="content" required="required" value="" />
<g:dialog_buttons_ok_cancel ok_text="${gs.getMessage('OK')}" ok="return actionOK();" cancel="return cancel();"/>

</g:ui_form>

</j:jelly>

Client Script :
function actionOK() {
var comments = gel("content").value;
comments = trim(comments);
alert(comments)
if (comments == "") {
//If comments are empty stop submission
alert("Please provide comments to submit the dialog.");
return false;
}
else
{
gel('jvar_answer').value = g_form.getUniqueValue();
    gel('contentvalue').value = gel('content').value;  
}

}

function cancel() {
GlideDialogWindow.get().destroy();
return false; //Close the dialog window
}

Process Script :

var app = new GlideRecord("incident");
if (app.get(this.jvar_answer)) {
app.comments= this.contentvalue;
app.state=6;
app.update();
response.sendRedirect(app.getLink(false))
}


Thanks,

BK

View solution in original post

5 REPLIES 5

Bhavya11
Kilo Patron
Kilo Patron

Hi All 

thanks for reply.

 

i have able to found the solution for make comments mandatory when state is changed from closed to Resolved

 

i have created ui action 

 

Name : Reopen incident 

Condition: gs.hasRole("itil") && current.state==7
Onclick: commentsDialog();
Action name: reoepn_inc_close
Script:

function commentsDialog() {
var message =g_form.getValue("short_description");
var dialog = new GlideDialogWindow("commmentpage"); 
dialog.setTitle("Add Comment"); 

dialog.setSize(750,300);
dialog.setPreference("sysparm_message", message); 
dialog.render(); 
}

Create the ui page;

Name : commmentpage

HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:ui_form>
<input type="hidden" id="jvar_answer" name="jvar_answer" value=""/>

<input type="hidden" id="contentvalue" name="contentvalue"/>
<input type="hidden" name="cancel_or_submit" id="cancel_or_submit" value=""/>

<textarea id="content" name="content" required="required" value="" />
<g:dialog_buttons_ok_cancel ok_text="${gs.getMessage('OK')}" ok="return actionOK();" cancel="return cancel();"/>

</g:ui_form>

</j:jelly>

Client Script :
function actionOK() {
var comments = gel("content").value;
comments = trim(comments);
alert(comments)
if (comments == "") {
//If comments are empty stop submission
alert("Please provide comments to submit the dialog.");
return false;
}
else
{
gel('jvar_answer').value = g_form.getUniqueValue();
    gel('contentvalue').value = gel('content').value;  
}

}

function cancel() {
GlideDialogWindow.get().destroy();
return false; //Close the dialog window
}

Process Script :

var app = new GlideRecord("incident");
if (app.get(this.jvar_answer)) {
app.comments= this.contentvalue;
app.state=6;
app.update();
response.sendRedirect(app.getLink(false))
}


Thanks,

BK