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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 10:21 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 10:32 PM
You can disable form submission with an "onSubmit" Client Script. Please refer to https://servicenowguru.com/scripting/stopping-record-submission-servicenow/ for an example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 10:33 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 10:37 PM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:04 PM
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;
}
}