- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 12:02 PM
I am trying to get the Sys_Id from the URL and then fetch the related records from a table.
I tried, data.sys_id = $sp.getParameter("sys_id"); in the server script ; but it doesn't fetch the sys_id from the URL.
Please assist.
Regards,
Yogesh PH
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2016 01:43 PM
Yogesh,
You want to use addQuery, as opposed to addEncodedQuery when looking up just the sys_id.
If you log ' $sp.getParameter("sys_id");', what does it return?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2016 02:10 PM
Hi Yogesh,
Could you please provide some more info so that I can assist? At first glance, that appears to be the correct use to get the sys_id from the URL.
- What does your URL look like?
- Where are you trying to use the sys_id? Client, Server or HTML?
- Please post the script for where you are retrieving the sys_id
- What is data.sys_id returning?
- Did you try to enable logging of the data object and check the console to see if it's populated? (CTRL-Right click widget and choose "Log to console: $scope.data")
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2016 12:15 PM
Hi paulw(acorio),
Below is the Server Query:
(function () {
data.tasks = [];
//data.sys_id = $sp.getParameter("sys_id");
var gr = new GlideRecord('u_u_task');
gr.addEncodedQuery('sys_id', $sp.getParameter("sys_id") );
gr.query();
while (gr.next()){
var task = {};
task.name = gr.getDisplayValue('u_uname');
task.details = gr.getDisplayValue('u_details');
data.tasks.push(task);
}
})();
This actually return the entire table content irrespective of the URL: /?sys_id=18e8634ddb6d62006430f7fdbf961976&view=sp&id=yogi_test5&table=u_u_task
Please share information of checking the log console.
Regards,
Yogesh PH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2016 01:43 PM
Yogesh,
You want to use addQuery, as opposed to addEncodedQuery when looking up just the sys_id.
If you log ' $sp.getParameter("sys_id");', what does it return?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 05:13 AM
Hi Paul,
Now how do i delete a record?
I put the below script in client script; but delete function doesn't work.
function deleteAlertRecords(){
var rec = new GlideRecord('u_u_task');
rec.addQuery('data.sys_id');
rec.query();
while(rec.next()){
spUtil.addErrorMessage("This record is deleted");
rec.deleteRecord();
}
}
Regards,
Yogesh PH