How can I get data from Tiny URL table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2025 09:13 AM - edited 02-04-2025 10:43 AM
When ingesting interactions with high char totals, I've found that the Tiny URL table (sys_tiny_url) receives the data but doesn't process it or pass it to the respective catalog item.
I'm trying to make a call to the table, receive the data and then set values within the catalog item.
My onLoad Catalog Client Script so far works correctly, makes the call and finds the data. The issue I'm finding is that the data from the Tiny URL table it all in one long string.
Is there an optimal way to massage this data, remove unwanted characters and set it to values?
Catalog Client Script:
function onLoad()
{
//Type appropriate comment here, and begin script below
//Use the GlideURL object to get the sysparm_tiny parameter from URL which is then passed into the script include
var urlparams = new GlideURL();
urlparams.setFromCurrent();
var tinyparam = urlparams.getParam("sysparm_tiny"); // get tiny url
alert(tinyparam); // print tiny url
// Ajax call to script include which does GlideRecord query to sys_tiny_url tabl;
var tinyGA = new GlideAjax("TinyURLData"); // call script include
tinyGA.addParam("sysparm_name", "getTinyURLParams"); // call script include function
tinyGA.addParam('sysparm_tinyid', tinyparam); // send over tiny url
tinyGA.getXML(getTinyURLParams);
alert('passed ajax');
}
function getTinyURLParams(response)
{
alert('entered tinyurl function');
var answer = response.responseXML.documentElement.getAttribute('answer');
//alert('answer is: ' + answer);
//g_form.setValue('variables._variable_name_', answer);
var resp = answer.split('=');
var bs = resp[0];
var ans1 = resp[1];
var ans2 = resp[2];
// testing split
alert('first answer: ' + bs);
alert('second answer: ' + ans1);
alert('third answer: ' + ans2);
}
Script Include:
var TinyURLData = Class.create();
TinyURLData.prototype = Object.extendsObject(AbstractAjaxProcessor,
{
getTinyURLParams: function()
{
var tinyID = this.getParameter("sysparm_tinyid");
var data;
gs.log('TINY URL: entered script include');
gs.log('TINY URL: The tiny url is ' + tinyID);
//testAnswer;
// Do a GlideRecord query on the sys_tiny_url table based on the value of sysparm_tiny passed in from onload client script
var turl = new GlideRecord('sys_tiny_url');
turl.addQuery('tiny_url', tinyID);
turl.query();
gs.log('TINY URL: post query');
if (turl.next())
{
gs.log('TINY URL: inside if')
tdata = turl.data;
//testAnswer = '5';
}
gs.log('TINY URL: answer before returning is: ' + tdata);
return tdata;
//return testAnswer;
},
type: 'TinyURLData'
});