Catalog client script to do a table lookup then insert the results in a multi-row variable set on the intake form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2019 09:58 AM
Back to the well again. I'm liking the new multi-row variable sets. I have a catalog item to request new servers. Originally, the requester said, if the user picks Windows then automatically populate the "drives" mrvs with a C drive and some values. They can add others to the mrvs but we need this required drive to automatically be there and if they pick Linux as the OS then automatically add "/", the size, the tier into the mrvs. I have the script that assumes I will hardcode either C or /.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var OSdrive = [
{
drive_letter_os: "CC",
drive_size_os: "test",
unit_os: "GBs",
disk_tier_os: "Premium_LRS",
sizeingbs_os: "333"
}
];
g_form.setValue('INTERNAL_NAME_OF_MRVS', JSON.stringify(OSdrive));
}
But now they added a custom table called "recommended drives" where they will dynamically store the C drive and / drive attributes as well as others. So now when the user selects the OS of Windows or Linux on the catalog item I can't just use my cat script and populate the mrvs, I have to lookup which drive or drives to insert into the mrvs based on what is in the Recommended Drive table. So today when I select the OS of Windows there might be Drives C and F with drive_letter, drive_size, unit, dis_ticket, sizeinbgs, I then need to insert those 2 rows into the mrvs on the intake form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 07:51 AM
yeah, i like a challenge and usually learn new stuff over the weekend. I have a deadline Friday to deliver something to my boss and i"m going to have to say, "can't do" over my head at the moment. I'm thinking of an alternate solution I can provide until I can do this.
I'm giving myself another hour
to work on a simple script include and then call from my catalog client script.
If I can pull one value from one table and populate one variable on the form, I'll see if I can then expand on that to pull whole rows of data from the table into a multi-row variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 07:58 AM
small eureka.
I now have a small script include and catalog client script that calls that include and I can get back a single value into a string variable field on the catalog form.
Now i have to turn that into pulling several rows from the table with multiple attributes into a mrvs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 07:59 AM
small eureka. 🙂
I now have a small script include and catalog client script that calls that include and I can get back a single value into a string variable field on the catalog form.
Now i have to turn that into pulling several rows from the table with multiple attributes into a mrvs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 08:06 AM
SI:
var getRecDrive = Class.create();
getRecDrive.prototype = Object.extendsObject(AbstractAjaxProcessor, {
driveDetails: function(){
var retVal; // Return value
var Dreq = this.getParameter('sysparm_id');
var gr = new GlideRecord('u_fnf_azure_request_form_recommend_drive');
gr.addQuery('u_description"',Dreq);
gr.query();
if(gr.next())
{
retVal = gr.u_size_unit;
}
return retVal;
},
type: 'getRecDrive'
});
CS:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var name = g_form.getValue('name');
var ga = new GlideAjax('getRecDrive');//name of script include
ga.addParam('sysparm_name', 'driveDetails');//name of function on script include
ga.addParam('sysparm_id', "x");//name of field on form triggering call
ga.getXML(getRecDriveLookup);
}
function getRecDriveLookup(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var answers = answer.split(',');
alert(answers);
g_form.setValue('justification',answers[0]);
//g_form.setValue('fieldBB',answers[1]);
//g_form.setValue('fieldCC',answers[2]);
//g_form.setValue('fieldDD',answers[3]);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2019 08:06 AM
Sounds like you got this coming together! Let me know if you need any help