Need help how to abort the Duplicate software request

mastanbabuk
Tera Contributor

If the Requested user has already the same software was assigned to him or he already submitted the request before for the same software. We just need to stop him like we need to show Error message after submit the request

2 REPLIES 2

MercBuilding
Giga Guru

Hi @mastanbabuk ,

   You can write on submit catalog client script and a script include to query on requested for and type of software from RITM table and if there is any match , you can display the error message and abort the action using client script.

 

Thanks!

Can someone help in my case please?

 

I have created the On submit client script and script include, But its not working returning the null value. Currently I am checking to get RITM number. But in alert it returing the NULL.

#clientscript 

function onSubmit() {
   
    var csd = g_form.getUniqueValue();
    var usr = g_form.getValue('user');

    var ga = new GlideAjax('GetClientName');
    ga.addParam('sysparm_name','checkRITMs');
    ga.addParam('sysparm_value', csd);
    ga.addParam('sysparm_User', usr);
    ga.getXML(GetSysid);
    return false;
    //alert(' this is from client script'+ usr);

    function GetSysid(response) {
        var answer = response.responseXML.documentElement.getAttribute(answer);
        alert('The Active Service Request is :' + answer);

        //answer = g_form.setAbortAction(true);
    }
    //return true;
 
 
#script include
 
checkRITMs: function() {
        
        var jump = this.getParameter('sysparm_value');
        
        var user = this.getParameter('sysparm_User');
       
        var ritm = new GlideRecord('sc_req_item');
        ritm.addEncodedQuery('state!=4');
        ritm.addQuery('cat_item', jump);
        ritm.addQuery('u_requested_for', user);

        ritm.query();
        if (ritm.next()) {
            
            return ritm.number;


        } else {
            
            return false;

        }
    },

    type: 'GetClientName'
});