How to get two input boxes by using spModal?

Sathwik1
Tera Expert

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;
        })
    }
}

@AnirudhKumar 

1 ACCEPTED SOLUTION

AnirudhKumar
Mega Sage
Mega Sage

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.

View solution in original post

4 REPLIES 4

Filipe Cruz
Kilo Sage
Kilo Sage

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:

find_real_file.png

 

Is this what you are looking for?

 

If this answer is relevant for you, please mark it as correct/helpful.

Thanks,

Filipe

Nope,

I am looking for spModal which can be used in portal..

AnirudhKumar
Mega Sage
Mega Sage

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.

Thank You!