Display popup when selecting a category in the service catalog

miyu
Tera Guru

I would like to write a client script that will display a popup when a category is selected.
But I don't know how to write it.
Please let me know.

 find_real_file.png

1 ACCEPTED SOLUTION

AnirudhKumar
Mega Sage
Mega Sage

The screenshot shows a portal page.

To show a pop here, we need to update the Categories widget on the left. (This is not simple, but let me try my best to guide you)

 

Navigate to sp_widget table, and open the record with name SC Categories.

You will find that the page is readonly. Now we need to clone the widget.

(Remember to recreate the Angular Provider(related list) for your new widget).

 

Now 2 major updates need to be done : 

1. Link the new widget to the sc_category page(you need to go to the sp_page table for this)

2. In your new widget, update the $scope.categorySelected function with extra script in the Client Controller.

 

Your extra script should call a modal window.

Check

https://www.w3schools.com/bootstrap4/bootstrap_modal.asp

 

 

 

Long Live ServiceNow!

View solution in original post

13 REPLIES 13

Allen Andreas
Administrator
Administrator

Hello,

You can use an onChange client script and set the field to the category field on the record.

Then in the script section you can use something like:

var cat = g_form.getValue('category');
alert("The category chosen is: " + cat);

So this would get the value from the category chosen and then show a pop-up (alert) with the value.

You haven't given any other information like...does it only need to pop-up if 'x' category? You can add that in by using something like:

var cat = g_form.getValue('category');
if (cat == 'value') {
alert("The category chosen is: " + cat);
}

So you'd change 'category' to the name of the category field (I assumed it was named category).

And then you'd change 'value' to the value of the category you'd like the alert/pop-up to show up for.

Please refer to documentation for more information/examples: https://developer.servicenow.com/dev.do#!/learn/courses/paris/app_store_learnv2_scripting_paris_scri...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I just wanted to check in on this and see if my above reply helped guide you correctly.

If so, please mark as Helpful and Correct.

Thanks! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you for your reply.
I'd like to have a popup here in the ServicePortal.
Do I need to write this script?

find_real_file.png

Yeah...

This is why it's very important you for to give us all the information, like a screenshot, etc. up front. Because all of these replies are thinking you're talking about something else.

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!