Reference Qualifier on the same table

danielbartholom
Mega Expert

Hi I am looking for some help please

I have a Cat Item on the Service Portal that has a lookup select box variable that references the technical system table.

I would like to create a new column on the technical system table called Data Tool Network Path. When I open the form for a selected Technical System

I will then enter the correct path here. There will be different paths for different Technical Systems.

What I am looking for is the correct reference qualifier to present the following on the cat item form

When someone selects a Technical System that has a path applied is there a way I can have this come up a a string field so the requester can see

the path for review on the form?

So on the form, the requester selects a Technical System from the lookup select box

The correct path should then appear in a new variable (string maybe?) below.

To date this has been completed by Catalog UI policies but I am hoping I can streamline this some what.

I hope the above makes sense and any help would be most appreciated. Happy to provide more information if anything is unclear. Even if this does not work on a string variable I am still interested to know how you can run a ref qual on the same table?

1 ACCEPTED SOLUTION

HI,

 

I saw your New thread. Will look into this and reply asap.

Can you close this thread by marking answer as correct.

Thanks,
Ashutosh

View solution in original post

32 REPLIES 32

Hi,

 

Hope you are well?

You very kindly helped me resolve an action I was attempting and I am hoping this reply links to that question. Basically I wanted information to appear on a string field from a table. 

I am now trying to do the same on a different form but it is not working. Can I please provide the information below for you to review and let me know if I have missed anything:

 

Form Fields

Reference field - Asset tag

String Variable - serial_number

What I am after:

When someone selects an Asset tag from the reference field (which references table alm_asset) the scripts should look on the alm_asset table for that Asset tag and then present the Serial Number (included in the record) and display it within the serial number form variable.

 

Script Include

Name - getAssetInfo (your original one was called getUserEmail)

Client Callable - True

Accessible from - All application scopes

Active - True

 

var getAssetInfo = Class.create();
getAssetInfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getApp:function(){
var app = this.getParameter('sysparm_app');
var dis;
var gr = new GlideRecord('alm_asset'); //Replace cmdb_ci_appl with your table name
gr.addQuery('sys_id',app);
gr.query();
if(gr.next())
{
return gr.serial_number; //Path should be replaced with you field which contains Path on technical system table
}
},
type: 'getAssetInfo'
});

 

Catalog Client Script

Applies to - A Catalog Item

Active - True

UI Type - All

Type - onChange

Variable name - asset_tag

Applies on a catalog item view - True

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getAssetInfo') ;
ga.addParam('sysparm_name','getApp');
ga.addParam('sysparm_app',newValue);
ga.getXML(hello);

function hello ()
{
var answer = ga.getAnswer();
//alert(answer);
g_form.setValue('serial_number',answer); //network_path is your variable where you want to store path
}
}

 

Can you identify where I might have got this wrong?

 

 

HI,

 

Can you do toString() when you return serial number.


THanks,
Ashutosh

Hi me again lol

 

Hope you are well and was wondering if you could help me because you have been an absolute legend so far!

 

I am looking to do the following and I am wondering if I can adapt the script you very kindly provided in this post to achieve:

 

On my Incident form I have a reference field called Technical System (references cmdb_ci) when I select Technical System GMV Video Conferencing I can click the dependency button and this will show me my End Points that are dependent on the Technical System (which is great) 

What I would like to do is add a field (list) under Technical System called Configuration Item. So when someone enters the Technical System GMV Video Conferencing only Ci/Components that are related to the Technical System would display for selection.

Am I correct in thinking that we would use the following table to do this cmdb_rel_ci?

Let me know if you need any further information.

Thanks

HI,

 

I saw your New thread. Will look into this and reply asap.

Can you close this thread by marking answer as correct.

Thanks,
Ashutosh

Hi Ashutosh,

 

I hope you are well. You very kindly helped me to get this request working for me and I have another question/scenario I would like to put past you if that is ok? If I can get what I need up and running it would be a huge benefit.

Are you ok for me to raise the question to you here?

Regards

Daniel Bartholomew