How to create sys property Reference type and List Type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 08:12 PM
How to create sys property Reference type and List Type so that we can select values from table instead of adding comma separated sys_ids.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 08:51 PM
@Varsha A Navigate to sys_properties.list and click on new to create a new property.
For reference type:
Type: Choose Reference from the dropdown.
Reference Table: Choose the target table you want to reference (e.g., cmdb_ci_computer, incident, user, etc.).
Default Value: This can be left empty or can be set to a default sys_id (if needed).
And for other Choose List from the dropdown.
To utilise properties in script :
Reference Property:
var refValue = gs.getProperty('your_table_reference_property');
var gr = new GlideRecord('cmdb_ci_computer');
gr.get(refValue); // Retrieves the referenced record based on the sys_id
List Property:
var listValue = gs.getProperty('your_table_list_property');
var sysIds = listValue.split(','); // Split the comma-separated sys_ids
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('sys_id', 'IN', sysIds);
gr.query();
while (gr.next()) {
// Process each record in the list or add your logic as per your requirement.
}
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 11:15 PM
we don't have type reference available : "Type: Choose Reference from the dropdown."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 08:53 PM
Hi @Varsha A ,
Did not understand you fully, Are you trying to get the reference value from property? Please explain bit more your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2024 11:18 PM
Hi @Runjay Patel , yes i want to create property of type reference or List, so that i can select values from table.
e.g. i would like to select user from the reference field.