Referencing tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 08:59 AM
Hi
I have a problem with referencing a table in the reference for field in service catalog item. Iam not able to understand the reason behind this.
To say clearly, I have a table 'u_group_owners' and a catalog item in which group name has to selected. for the field 'Group Name', I choose type of
field 'Reference' and in the type specifications I don't get the table name. I have checked the properties but dint find anything.
Then, I selected another table 'sys_user_group' and was able to select the group name but again had a problem. In the workflow for that item, I had
to write a approval activity sending emails to approvers in which I have to query the group owner of the specified group. In the script, Iam not able to
retrieve other column names from the table because the Display value is set to False. And only any one column can be changed its display value to
True.So, If I change the group owner field , group name display value is changed to false and I cannot select the group name in catalog form.
Someone help me with the two issues Iam struggling from three days?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 09:59 AM
Hi,
harshini elath wrote:
in the type specifications I don't get the table name. I have checked the properties but dint find anything.
Is the table scoped??
Did you search the right name (the table label)?
In the workflow for that item, I had
to write a approval activity sending emails to approvers in which I have to query the group owner of the specified group. In the script, Iam not able to
retrieve other column names from the table because the Display value is set to False. And only any one column can be changed its display value to
True.So, If I change the group owner field , group name display value is changed to false and I cannot select the group name in catalog form.
Did you use advanced script to send users?
use
answer =[];
var grp= new GlideRecord('table_name');
grp.addQuery('sys_id',current.variables.variable_name.toString());
grp.query();
if(grp.next()){
answer.push(grp.getValue('sys_id'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2017 10:14 AM
Please provide a snapshot. This is basic Service Now functionality and it should work unless the table is scoped or has security rules preventing it from being read. If you are adding a variable to a catalog item, in your catalog item, you should be clicking on Variable related list and adding new variables from there.
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2017 06:21 AM
Hi I found the reasons behind the two issues
For the table name to appear in reference field, there was a error in our system when creating that specific table which made the Active property to False which would be true by default.
So I did Dictionary>search table name>Under Collection type dictionary entry>making Active field to True solved the issue.
For the second issue, as the column name I was trying to access was a reference field, I had to do more dot-walking.
Like
var gr=new GlideRecord('table_name')
gr.addQuery('col_name',current.variable)
gr.query()
if(gr.next()){
gs.log(gr.col_name.name) //if it is reference column
}