- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 02:54 AM
Hi,
I am trying to create a custom history line record for User (Sys ID mentioned as XYZ) via a script.
The script doesn't seem to be working.
I do understand that i cannot set value like below but don't know the solution.
history.set.id='XYZ';
Any suggestions
var historySet = new GlideRecord('sys_history_set');
historySet.addQuery('id', 'XYX');
historySet.query();
if (historySet.next())
{
var history = new GlideRecord('sys_history_line');
history.initialize();
history.set.id='XYZ';
history.field='Role Optimization';
history.type='relation';
history.label='relation';
history.relation='Role Optimization';
history.old='User Removed from Groups ';
history.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 03:10 AM - edited 01-18-2023 03:11 AM
Hi @Wasim Akhtar ,
Can you try below,
var historySet = new GlideRecord('sys_history_set');
historySet.addQuery('id', 'XYX');
historySet.query();
if (historySet.next())
{
var history = new GlideRecord('sys_history_line');
history.initialize();
//history.set.id='XYZ';
history.set = historySet.getUniqueValue(); // This will return XYZ or you can use historySet.getValue('sys_id');
history.field='Role Optimization';
history.type='relation';
history.label='relation';
history.relation='Role Optimization';
history.old='User Removed from Groups ';
history.insert();
Please mark correct it it helps.
Thanks,
Pratik Malviya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 03:10 AM - edited 01-18-2023 03:11 AM
Hi @Wasim Akhtar ,
Can you try below,
var historySet = new GlideRecord('sys_history_set');
historySet.addQuery('id', 'XYX');
historySet.query();
if (historySet.next())
{
var history = new GlideRecord('sys_history_line');
history.initialize();
//history.set.id='XYZ';
history.set = historySet.getUniqueValue(); // This will return XYZ or you can use historySet.getValue('sys_id');
history.field='Role Optimization';
history.type='relation';
history.label='relation';
history.relation='Role Optimization';
history.old='User Removed from Groups ';
history.insert();
Please mark correct it it helps.
Thanks,
Pratik Malviya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 03:56 AM
thanks for your help @Pratik Malviya