Virtual agent
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2024 10:50 PM
(function execute() {
/* Code your script logic here. For example, you might want to call an external web service
to find the best local Italian restaurants. Call a Restaurants Web Service then use the results
to populate a rows array.
var headers = [
'Name', // Column 1 header
'Description' // Column 2 header
];
var rows = [];
rows.push([ // Row 1
'De Napoli', // Column 1 value
gs.getMessageLang("Best Italian Restaurant Ever", vaContext.getRequesterLang()) // Column 2 value
]);
rows.push([ // Row 2
'Albertos', // Column 1 value
gs.getMessageLang("Even Better Italian Restaurant", vaContext.getRequesterLang()) // Column 2 value
]);
return {
columnHeaders: headers,
columnValues: rows
};
*/
var headers = ['Access', 'Endpoint']; // Define column headers
var rows = []; // Array to hold row values
var roleObject = {};
var userRoles = new GlideRecord('tablename');
userRoles.addQuery('directory.servicenow_id', gs.getUserID());
userRoles.addQuery('stage', '=', 'granted'); // Ensure the 'stage' field is correct
userRoles.orderBy("iam_roles.application");
userRoles.query();
while (userRoles.next()) {
var roleID = userRoles.getDisplayValue('iam_roles');
roleObject[roleID] = userRoles.getDisplayValue('iam_roles.application');;
// Push each role and application as a row
rows.push([roleID, roleObject[roleID]]);
}
// Return the table structure
return {
columnHeaders: headers, // Column headers for the table
columnValues: rows // Row values for the table
};
})();
This code i have written in table form bot response in virtual agent.This is giving me the correct output currently its giving me in this format
This code i have written in table form bot response in virtual agent.This is giving me the correct output currently its giving me in this format
But i need access and endpoint should come in separate column,below i have pasted the reference of it
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2024 12:34 AM
I mean check the log and tell me what is coming in log for gs.info("Rows Array: " + JSON.stringify(rows));
and
gs.info("Access: " + access + ", Endpoint: " + endpoint);
--------------------------------------------------------------------------------------------------------------------------
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2024 12:57 AM - edited ‎10-29-2024 12:59 AM