Create a modal with text input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 11:40 AM
We currently have an onSubmit client script in Incident that triggers a prompt component pop-up under certain conditions. It would ask users to enter texts:
If "Proceed" is entered correctly, the record saves, and if not, it aborts.
Is there a way to make this a modal? I have looked around and only seen modals without the text field.
Thanks,
Solomon
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2022 11:53 AM
Hello ,
yes we can do it through sPModal Api
follow below steps :
1) In your on submit client script use this .
spModal.open is a method which is used to open modal windows and you can call your widget in widget parameter where you can create your input box.
You can change your title accordingly using title attribute
and you i widget parameter use your widget iD
Size you can have three sizes , xs,md,lg where i gave medium
function onSubmit()
{
spModal.open({
title: 'MY MOdal',
widget: "my_modal_id",
widgetInput: "",
size:"md"
}).then(function(){
}) ;
}
2) Create a widget with the same ID that you mentioned in widget parameter
Navigate to widgets -->create new -->paste below HTML script
<div>
<label for="mytext">My Input:</label>
<input type="text" id="mytext" name="mytext">
</div>
For more info on spModal Api refer below link :
https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/SPM-open_O
please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 10:52 AM