- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:22 AM
How to get two input boxes by using spModal... by using the below I am getting one..I need one more input box as well..
function(spModal) {
var c = this;
c.onOpen = function() {
//ask the user for a string
spModal.open({
title: 'Give me a name',
message: 'What would you like to name it?',
input: true,
value: c.name
}).then(function(name) {
c.name = name;
})
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 07:02 AM
Hello Sathwik,
That maybe possible with embedding a widget in the spModal.
Frankly I have never used spModal for popups, I always go for the traditional Modal Window.
Here's the link :
https://www.w3schools.com/bootstrap/bootstrap_modal.asp
Using Modal window you are free to create as many input boxes, forms or anything you need inside your pop up.
Difference between spModal and Modal Window
SpModal | Modal Window |
Built by ServiceNow, works only inside ServiceNow portal | Its open source concept, can be used anywhere |
Makes it easy to quickly create simple popups |
Takes few extra minutes to do the same job |
You only give parameters, and ServiceNow creates the elements |
You have to write out the HTML tags manually |
Complex designs are harder to achieve, due to lack of transparency (knowing what is going on) |
Even complex designs are relatively easier achieve (we can see what is going on coz we write the HTML tags from scratch) |
Learning how to use Modal Window takes some effort, but after 1-2 days, you will fall in love with it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:30 AM
Hello!!
Please check the following link that, for sure, will help you!
Workspace UI Actions
You can use a code like this:
function onClick(g_form) {
var fields = [{
type: 'textarea',
name: 'work_notes',
label: getMessage('Reason'),
mandatory: true
},
{
type: 'choice',
name: 'reason_code',
label: getMessage('Reason code'),
value: getMessage(' -- Select -- '),
choices: [{
displayValue: 'Because I want to',
value: 'illdowhatiwant'
},
{
displayValue: 'Not sure',
value: 'notsure'
}
],
mandatory: true
},
{
type: 'reference',
name: 'caller_id',
label: getMessage('What is your name?'),
mandatory: true,
reference: 'sys_user',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue()
}
];
g_modal.showFields({
title: "Enter your reason",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('work_notes', fieldValues.updatedFields[0].value);
g_form.setValue('caller_id', fieldValues.updatedFields[2].value);
g_form.save();
});
}
And the result will be:
Is this what you are looking for?
If this answer is relevant for you, please mark it as correct/helpful.
Thanks,
Filipe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 03:16 AM
Nope,
I am looking for spModal which can be used in portal..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 07:02 AM
Hello Sathwik,
That maybe possible with embedding a widget in the spModal.
Frankly I have never used spModal for popups, I always go for the traditional Modal Window.
Here's the link :
https://www.w3schools.com/bootstrap/bootstrap_modal.asp
Using Modal window you are free to create as many input boxes, forms or anything you need inside your pop up.
Difference between spModal and Modal Window
SpModal | Modal Window |
Built by ServiceNow, works only inside ServiceNow portal | Its open source concept, can be used anywhere |
Makes it easy to quickly create simple popups |
Takes few extra minutes to do the same job |
You only give parameters, and ServiceNow creates the elements |
You have to write out the HTML tags manually |
Complex designs are harder to achieve, due to lack of transparency (knowing what is going on) |
Even complex designs are relatively easier achieve (we can see what is going on coz we write the HTML tags from scratch) |
Learning how to use Modal Window takes some effort, but after 1-2 days, you will fall in love with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 07:07 AM
Thank You!