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

Bhavya11
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

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

Tran Phu
Tera Contributor

Hi @Bhavya11 ,
If it is not visible for ITIL, why do we make them mandatory?
For that requirement, You can create a UI policy/ client script (On submit) to achieve it.

Community Alums
Not applicable

hi @Bhavya11 

 

How you have allowed user to change state from closed to resolved ??

Once I have deactivated the flow : Resolve blocked by record if Incident is closed and UI Policy :Make fields read-only on close. I am getting the worknote and additional comment visible.

 

- Check your Client Scripts to see if this field is mentioned in any script where if the state if Closed, to setVisible or setDisplay is false, meaning it's hiding it.

 

Please mark the response helpful and accept it as solution

 

Thanks

Akash

 

Hi @Community Alums 

 

i have checked all Client script and UI policy but didn't get any luck on that. so  i have tired the using UI page and copy the comment to incident table after submitting ok (below screenshot for reference)  but its not working for ITIL user only works for Admin.

Bhavya11_0-1679046155862.png

 

 

Regards,

BK

 

Community Alums
Not applicable

hi @Bhavya11 

You need to check the ACL as it can be most probable reason the field is not coming up for ITIL user while it is coming for Admin user.

 

Please mark the response helpful and accept it as solution

 

Thanks

Akash