The CreatorCon Call for Content is officially open! Get started here.

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

Maik Skoddow
Tera Patron
Tera Patron

You can disable form submission with an "onSubmit" Client Script. Please refer to https://servicenowguru.com/scripting/stopping-record-submission-servicenow/ for an example.

Sid_Takali
Kilo Patron

Hi @prasannakumard you can write a below script in Script field, which will block the submission.

var uID =   current.requested_to;
var grmember = new GlideRecord('sys_user_group'); 
grmember.addQuery('manager', uID);
grmember.query(); 
while(grmember.next()) 
{ 
//your logic
current.setAbortAction(true);
} 

 

Regards,

Sid

@Sid_Takali Actually, I'm trying to stop submission in Catalog form. Please see above script for the same. I can't able to stop the submission. Please suggest any solution regarding the same.

Thanks & Regards,

Prasanna Kumar

Sanket Landge
Tera Expert

Hello @prasannakumard,

 

If you want this type of validation then you need to use the DOM manipulation which is not recommended my ServiceNow.

 

But if you are fine with DOM then you can refer below script in client script servicenow

var refs = document.getElementsByTagName("button");

var reuestedFor = g_form.getValue("requested_for").toString();
if (refs && (requestdFor.length==0)) {
for (var i=0; i < refs.length; i++) {
var ref = refs;
var inner = ref.innerHTML;
if (inner == 'Submit'){
ref.disabled = true;
}
}