- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2020 11:28 PM
Hi Guys,
I am trying to set 'additional comments' journal field of change form with some answers given by end users for record producers. I can able to set same for existing record but when a new record is being created at the same time i want to set additional comments field. In my script I am getting current.sys_id as blank , so basically my question is how to return sys_id of newly created change request to record producer script?
Working code for existing record in record producer script
{
gr1.comments.setJournalEntry('test');
gr1.update();
}
{
gr1.comments.setJournalEntry('test');
gr1.update();
}
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2020 01:31 AM
You do not need the current.update()
The assignment group is set? (so it gets to the part in the 'if (gr.assignment_group)')
Can you try removing current.update().
You are setting it in the 'Script', right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2020 12:07 AM
You do not have to query the record or update. Since it has to be created you can refer to current to set the values of the record that will be created, like this:
var gr1 = new GlideRecord('change_request');
gr1.addQuery('sys_id','adeec8501bc710109bda7596cc4bcbe8');
gr1.query();
if(gr1.next())
{
gr1.comments.setJournalEntry('test');
gr1.update();
}
current.comments = 'test';
For more info refer to:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2020 12:40 AM
current.comments = 'test'; is not working however I can set other values like short_description with the same syntax
current.short_description = "test";
I tried with current.comments.setJournalEntry('test') also but no luck. however when I am using setJournalEntry() with glideRecord its working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2020 12:53 AM
In OOTB Record producers the "current.comments =" is used. So it should work.
Is the comments set somewhere else before?
You could try:
current.comments += 'test';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2020 01:18 AM
Still not working willem:(
var a = current.getValue('cmdb_ci');
gs.addInfoMessage("Assignement group of CI=" + a);
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('sys_id', a);
gr.query();
if (gr.next()) {
gs.addInfoMessage("Support Group Found" + gr.assignment_group);
if (gr.assignment_group) {
current.assignment_group = gr.assignment_group;
//gs.addInfoMessage("sys-id",current.sys_id);
current.comments += 'test';
current.work_notes += "Testing work notes";
current.short_description = "Test Short Descrioption";
current.update();
} else {
gs.addInfoMessage("CI not having group");
current.setValue('assignment_group',id,name);
current.update();
}