Write a code for server script for fetching a custom table value ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2024 11:37 PM
16 REPLIES 16
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 12:17 AM
Hi @1dusjhyahnt
try this :
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
/*1. Declare the array*/
var myArray =[];
/*2. Glide record on table*/
var grInc = new GlideRecord('u_artificatory');
grInc.addQuery('sys_id','458688b893c04210e4f0398efaba10e7');
grInc.query();
if(grInc.next()){
/*2.1 Create empty object*/
var myObject = {
};
/*2.2 Set object values*/
myObject.name = grInc.getValue('u_name'); //updated
myObject.class = grInc.getValue('u_class'); //updated
/*2.3 Push object in array*/
myArray.push(myObject);
}
/*3. Set array to data */
data.values = myArray;
gs.addInfoMessage(data.values[0].name); //updated
gs.addInfoMessage(data.values[0].class); //updated
})();
Vishal Birajdar
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 12:22 AM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 12:26 AM
hmm...strange...
May be because of 'class' identifier
try this....
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
/*1. Declare the array*/
var myArray =[];
/*2. Glide record on table*/
var grInc = new GlideRecord('u_artificatory');
grInc.addQuery('sys_id','458688b893c04210e4f0398efaba10e7');
grInc.query();
if(grInc.next()){
/*2.1 Create empty object*/
var myObject = {
};
/*2.2 Set object values*/
myObject.name = grInc.getValue('u_name');
myObject.class_name = grInc.getValue('u_class'); //updated
/*2.3 Push object in array*/
myArray.push(myObject);
}
/*3. Set array to data */
data.values = myArray;
gs.addInfoMessage(data.values[0].name);
gs.addInfoMessage(data.values[0].class_name);
})();
If this is not working then check in background script once...
Vishal Birajdar
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 12:32 AM
now working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2024 01:29 AM
Cool....!!!
Vishal Birajdar
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates