- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 10:45 PM
Hi,
we have the below scenario for one of our client.
based on employee type we need to show submit button to submit the request on service portal.
for this I have written client script on onload. But not understanding how to achieve this
if(g_form.getValue(employee_type) == ‘full time’){
show submit button
}else {don’t show}
please help me with the scripting
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 04:59 AM
are you sure Isolate script field is marked as False for your client script?
Share the latest script and what debugging have you done so far?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 10:58 PM
Hi Kaveri
I would suggest try to achieve this by using server side script as I think you don't have any value related to employee
because g_form is not going to access to user data
It would be better if you can attach your Catalog item snap to getter better idea
Thanks,
Bhanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:02 PM
Hi @Are Kaveri,
Use the below method in the client script:
this.jQuery('button').hide();
Or, if a catalog item is just for informational purposes without any fields/values in it, I recommend you to create a Content Item instead of a Catalog item. Content Item does not contain these buttons and can be used in place of the catalog item.
I hope this will help you solve your problem. Please mark it as Accepted and Helpful.
Thanks and Regards,
Anshul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:08 PM
it is a record producer.
my scenario is that
for employee type = full time
allow submission
if employee type = part time
he was given a popup msg and submit button should be hidden.
i have written below script for hiding button.
But i want it based on employee type condition that i am unable to achieve using below script.
if(window == null){
var z = this.document.getElementsByClassName("btn btn-primary btn-block ng-binding ng-scope");
z[0].style.display = 'none';
}else{
document.getElementById("submit_button").style.display = 'none';
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:16 PM
Hi,
Not sure if hiding the submit button will be a good approach.
Might be better to highlight the form, or some variable to have the user make other selections.
Anyhow, a Catalog Client Script can prevent submitting the form if some specific conditions happen, like this:
function onSubmit() {
if (some_condition_that_should_prevent_submit){
g_form.addInfoMessage('You cannot submit because... some reason');
return false;
}
}