[Tips & Tricks] Script To Non-Mandate Item When Sub-Category Is Empty

[Tips & Tricks] Script To Non-Mandate Item When Sub-Category Is Empty

Classifying requests using Categories, Sub-categories and Items plays a vital role in the ticketing environment. Some key benefits are:

  • It helps the organization to quickly route the tickets.
  • Increases the efficiency of support workflow.
  • Support analyzing the nature of recurring incidents.
  • Paves way for better reporting.

Scenario:
One of our community users requested a function to non-mandate the item field in the request template when a sub-category with an empty item is selected in a request form. We all would have come across certain scenarios where category, the sub-category will not have items configured. In his organization, they have mandated the CSI's in all request templates via FAFR to ensure they get the best metrics when reporting. As all the CSI fields are marked as mandatory, ServiceDesk does not allow the user to submit the ticket without filling up the item. We provide the following FAFR based script to non-mandate the item field when the sub-category does not have an item configured. We thought sharing this script along with configurations steps as an article will be useful for other community users.


Script:

var subCategoryID = $CS.getValue("SUBCATEGORY");
var fetch_items_url = "/api/v3/subcategories/" + subCategoryID + "/items";
input_data = '{"list_info": {"row_count": 1000,"get_total_count": true,"search_fields": {"deleted": "false"}}}';

jQuery.ajax({
    url: encodeURI(fetch_items_url),
    type: 'GET',
    dataType: 'json',
    headers: {
        'Accept': 'application/json'
    }, //NO I18N
    data: {
        'input_data': input_data
    },
    success: function(response) {
        total_count = response.list_info.total_count;
        if (total_count === 0) {
            $CS.nonMandateField(["ITEM"]);
        }
        else if(total_count >0){
            $CS.MandateField(["ITEM"]);
        }
    },
    cache: false,
    async: false
});

Prerequisites:

>> Create a Global FAFR (On-Form Load) to mandate CSI fields.




>> Create a Global FAFR (On Field Change) configure the rule as in screenshot with the script.



>> On request submission when the request template gets loaded, the CSI fields get mandated.  



>> When the sub-category is selected FAFR (On Field Rule) checks and non-mandates the item when the sub-category does not have the item configured.



>> Request gets created.



Thank you for your time, we hope you find this article useful!


Our previous article was on - Autoselect SLA for Service request based on User Site info 


              New to ADManager Plus?

                New to ADSelfService Plus?