Popup on change request form when user clicks on a ui action and state is in draft or new

Poorva Bhawsar
Mega Sage

Hi Community,

 

I have a custom field created on the change form which is a checkbox field. Until user check that checkbox and there are no related items in the change requests related list, i want to show an alert. Also, when user clicks on request approval ui action and state is new or draft all the time then i want to show same alert. Any one condition satisfies then want to show this alert i.e. either that checkbox is checked or there are no related items in the related list then show alert.

 

var gr = new GlideRecord('change_request');
//gr.addQuery('parent', value);
//gr.addQuery("unable to test in PPT", false);
gr.addEncodedQuery("parent=^ORu_non_production_test_not_required=false");
gr.addQuery("state", -5);
gr.query();
if (!gr.next()) {
    gs.addInfoMessage('A valid non production change must be linked in the "Change Requests" related list or justification for no non-production test evidence provided via the "Non Production Test Not Required" checkbox.');
}
 
This is the script but its not working.
6 REPLIES 6

Harsh_Deep
Giga Sage
Giga Sage

Hello @Poorva Bhawsar 

 

It seems that your "gr.addEncodedQuery("parent=^ORu_non_production_test_not_required=false");" condition is not correct

Because you have used parent=Or
So fix this and this will work.

 

 

Mark Correct if this solves your issue and also mark 👍Helpful if you find my response worthy based on the impact.

Thanks

Poorva Bhawsar
Mega Sage

Hi,

 

I want to show an error message when change request moved to assess state.

When to run condition is state changes to assess.

(function executeRule(current, previous /*null when async*/ ) {

    var value = g_form.getUniqueValue();
    var gr = new GlideRecord('change_request');
    gr.addQuery('parent', value);
    gr.addQuery("u_non_production_test_not_required", false);
    gr.query();
    if (!gr.next()) {
        gs.addErrorMessage('A valid non production change must be linked in the "Change Requests" related list or justification for no non-production test evidence provided via the "Non Production Test Not Required" checkbox.');
    }
})(current, previous);
 
But this code is not working. How to show error message when they didnt check this checkbox or there are no related items under change requests related list.
 
Thanks