- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 10:15 PM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 03:22 PM
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);
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 02:56 AM
var serviceTypeGR = new GlideRecord('x_1296451_legaladv_servicetype');
I try this one still not get get response please suggest if i am wrong

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2024 04:06 PM
Never saw a Table in Servicenow of this type. The table should be in all small letters. Please check the table name
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 02:59 AM
thank you for your responses as per your suggestion i try
var serviceTypeGR = new GlideRecord('x_1296451_legaladv_servicetype');
still not get response let me know still you see wrong

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 05:04 AM
Can you please post screen shots of both Script include & Client script. Now, I suspect these
- ACL on Script include - this should be given to snc_internal
- Is the parameter getting the value and is the value exists in the given table
- Have you tried using the Javascript executer and pass a hardcoded value for "sysparm_selectedType"?
Thanks,
Narsing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2024 11:29 AM
Script Include:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var selectedType = g_form.getValue('type');
g_form.addInfoMessage("selectedValueInClient" + selectedType);
// Fetch Questions based on the selected Type using GlideAjax
getQuestionsBasedOnType(selectedType, function(questions) {
g_form.addInfoMessage("CheckResponse", questions);
// Check if the response has an error
if (questions && response.responseXML && response.responseXML.documentElement) {
var errorMessage = response.responseXML.documentElement.getAttribute('error');
if (errorMessage) {
g_form.addInfoMessage('GlideAjax Error:', errorMessage);
}
}
// Create and show the popup
var dialog = new GlideDialogWindow('ServiceRequestGuidance');
dialog.setTitle("Legal Service Matters Detail");
dialog.setWidth(600);
dialog.setHeight(400);
var html = "<div>";
for (var i = 0; i < questions.length; i++) {
var question = questions[i];
html += "<label>" + question + "</label>";
html += '<input type="text" id="question_' + i + '"/><br>';
}
html += '</div>';
dialog.renderWithContent(html);
dialog.setPreference('selectedType', selectedType);
dialog.setPreference('numOfQuestions', questions.length);
dialog.setPreference('table', g_form.getTableName());
dialog.setPreference('recordSysId', g_form.getUniqueValue());
dialog.show();
});
}
function getQuestionsBasedOnType(selectedType, callback) {
var ga = new GlideAjax('FetchPromptStrctureBasedOnChangeServiceType');
ga.addParam('sysparm_name', 'getQuestionsBasedOnType');
ga.addParam('sysparm_selectedType', selectedType);
ga.getXML(function(response) {
if (response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
var questions = answer.split(',');
callback(questions);
} else {
alert("Empty or invalid 'answer' attribute in the response from the server.");
}
} else {
alert("Empty or invalid response received from the server.");
}
});
2) Yes parameter get value as id both side client side and server side .and i get type which value of service type table .
3)
- Have you tried using the JavaScript executer and pass a hardcoded value for "sysparm_selectedType"? -- yes as upper screen shot you can see value of service type which I check from inspect element which is right ?