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.

Make Resolution Information section visible only when incident/request created

Pandu3
Tera Contributor

Hi Team,

 

I have a requirement , when incident/request created to related Case then only make visible resolution information section on case record. If incident not created then I need to make invisible entire resolution information section and if request created then I need to make resolution information section visible but under this section I need to hide "Resolution Code" field. Can anyone help me on this requirement . Thanks in advance.

 

 Case have either Incident or Request only

 

Pandu3_0-1683713741294.png

 

1 ACCEPTED SOLUTION

Dear @Pandu3 

Please use the below :

1. Client Script On Load  on the case request

var gaRequest = new GlideAjax('checkParentExists');
gaRequest.addParam('sysparm_name', 'getParent');
gaRequest.addParam('sysparm_parent', g_form.getUniqueValue());
gaRequest.getXMLAnswer(checkParent);
function checkParent(answer) {
alert(answer);
if(answer == 'true'){
g_form.setSectionDisplay('resolution_information',true);
g_form.setVisible('resolution_code',false);
}else{
g_form.setSectionDisplay('resolution_information',false);

}
}

 

Script Include - client callable

var checkParentExists = Class.create();
checkParentExists.prototype = Object.extendsObject(AbstractAjaxProcessor, {
 
getParent : function(){
var result;
var CaseSysId = this.getParameter("sysparm_parent");
 
        var grRequest = new GlideRecord('sc_request');
        grRequest.addQuery("parent", CaseSysId);
grRequest.query();
if(grRequest.next()){
result = "true";
}else{
result = "false";
}
        return result;
},
 
    type: 'checkParentExists'
});
 
KB18_0-1683876435995.png

 

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

View solution in original post

11 REPLIES 11

Dear @Pandu3 

Please help me in case you have request field in the case form.

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

KB18
Tera Guru

Dear @Pandu3 

 

Please write another UI Policy with condition Request is empty

Write the script in the Execute if True 

g_form.SetSectionDisplay('resolution_information', false) //give correct section name

 

Write the script in the Execute if False 

g_form.SetSectionDisplay('resolution_information', false)

g_form.setVisible('resolution_code',false);

 

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

Pandu3
Tera Contributor

Dear @KB18 ,

 

Can you please guide me how to check the "Request is Empty" condition on case form through UI policy.

Pandu3_0-1683865793229.png

Thanks.

Dear @Pandu3 

As per your request, I believe you have request field (Refence field to sc_request table) in the  Releated Record section in the case form. use that request field in the condition..

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

Pandu3
Tera Contributor

Dear @KB18 ,

FYI, I don't have any reference field on case level. I have only the related list.

Pandu3_0-1683868256487.png