How to disable/not editable Submit button for record producer in Portal and Native view?

prasannakumard
Tera Guru

Hi Team,

 

I need to make readonly/Disable "Submit" button in both Native and Portal view for below scenario:

 

If "Requested for" is not a manager, I need to Disable/Make readonly Submit button in both the Native and Portal view.

 

Please suggest how can I achieve this scenario.

 

Thanks & Regards,

Prasanna Kumar

8 REPLIES 8

PrashantLearnIT
Giga Sage

Hi @prasannakumard 

 

Most probably you cannot disable submit button based on condition, but you can write onsubmit client script

to check if user is not manager, then submission is not allowed.

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

@PrashantLearnIT Thank you for your quick response. Yes, I've written the below onsubmit script but, it is not stop the submission:

var userGA = new GlideAjax("global.CatalogClientScriptUtils");
    userGA.addParam("sysparm_name", "isManagerOf");
    userGA.addParam("sysparm_reqFor", g_form.getValue('requested_for'));
    userGA.getXMLAnswer(disableGroup);

    function disableGroup(answer) {
        alert(answer);
        if (answer == 'false') {
            g_form.addErrorMessage("You don't have permissions to add/remove members.");
            return false;
        }

    }
Please let me know any other possibilities to stop the submission.
Thanks & Regards,
Prasanna Kumar

Hi @prasannakumard 

when using GlideAjax in an onSubmit Client Script you have to follow a certain pattern. Otherwise it will not work. Please refer to ServiceNow's official knowledge article about the same: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579 

Hi @prasannakumard 

 

Can you please use if (answer == false)  instead of if (answer == 'false')?

 

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************