Not Get response From Server Side Script Include

payalpatel26
Tera Contributor
var FetchPromptStrctureBasedOnChangeServiceType = Class.create();
FetchPromptStrctureBasedOnChangeServiceType.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    // Function to fetch questions based on the selected type
    getQuestionsBasedOnType: function (selectedType) {
        var selectedType = this.getParameter('sysparm_selectedType');
gs.addInfoMessage("serverSideType"+selectedType);
 
        // Query the 'ServiceType' table and retrieve questions
        var serviceTypeGR = new GlideRecord('ServiceType');
serviceTypeGR.addQuery('type', selectedType);
serviceTypeGR.query();
 
        if (serviceTypeGR.next()) {
            var promptStructure = serviceTypeGR.getValue('promptstructure');
            return promptStructure ; // Return an empty string if PromptStructure is null
        }
 
      
    },
 
    type: 'FetchPromptStrctureBasedOnChangeServiceType'
});

 

1 ACCEPTED SOLUTION

Please also take a screenshot of the other field - promptstructure.

 

But even from this screenshot a problem can be seen: type is of type String in which you are looking for a sys_id.

That is theoretically possible but very NOT likely.

So the problem could be line

serviceTypeGR.addQuery('type', selectedType);

in the Script Include.

It is possible and likely that what you mean is:

serviceTypeGR.addQuery('sys_id', selectedType);

which can be short-handed to:

...
// Query the 'ServiceType' table and retrieve questions
var serviceTypeGR = new GlideRecord('x_1296451_legaladv_servicetype');

if (serviceTypeGR.get(selectedType)) {
	gs.addInfoMessage('serviceoog' + serviceTypeGR);
	promptStructure = serviceTypeGR.getValue('promptstructure');
}

gs.addInfoMessage('promptStructure ' + promptStructure);
...

View solution in original post

22 REPLIES 22

I'm not sure where you are running g_form.getUniqueValue() but it for sure works in Client Scripts.

Now you must also take into consideration where you want this pop-up to show: Core UI, Portal or Workspace.

Pretty much each medium/environment needs its own solution.

The supported API vary wildly between the 3.

For Core UI and Workspace you could write a UI Page which can be shown with help of GlideDialogWindow in Core UI and g_modal.showFrame in Workspace.

Portal would have its own widget based solution.

UI Pages are the same stuff as Tomcat or PHP or ASP: it generates HTML pages.

GlideDialogWindow is the API that "contacts" the server, requests the HTML page, fetches it and displays it in a dialog.

That means that in this case you would not need GlideAjax.

 

If what you want is to show a list, I have recently helped out someone with a similar situation; have a look at the accepted solution; that can help you display a list filtered to what is needed.

If your intention is not only to display a list based on which service type has been selected, but also to ask for input and do something with that input, you need to describe the whole business need.

Actually that would be a good idea anyway.

Once you provide that info I will be able to tell you exactly how to use UI Pages and GlideDialog to accomplish it.

payalpatel26
Tera Contributor

GlideTabs2 findTabIndexByID could not find section_tab.7e7ced37c0a8000900873b9fdbfdc33a i find in the console as well as

This error is most likely not related at all to this problem.