Getting the value from journel field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2017 11:02 AM
Hi All,
I have to take work notes information from the incident table and have to set it to close notes. for that I have written no change client script
var state = g_form.getValue("state");
if( state != '6' || state != '7'){ // when state is resolved or closed
return;
}
var test = g_form.getValue("work_notes");
alert(test); // getting the value here
g_form.setValue('close_notes', test); // please correct me for this statement(Value is not assigning to close notes.
}
Kindly help me with this.
Thanks in advance..
Thanks and Regards
Laxman Boddu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2017 11:21 AM
Hi Laxman,
getValue() or setValue() functions don't work on journal entry fields. So if you have to copy the work notes into close notes you have to create a display business rule and save the work notes value into a scratchpad variable
g_scratchpad.workNotes= current.work_notes.getJournalEntry(-1);
and use the scratchpad variable in your client script. You can use the link as reference.
Thanks,
Nitin.
Hit Like, Helpful or Correct based in the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2017 11:51 AM
Hi,
I am proving you a solution in client script itself. But Please use Asynchronous Ajax call to execute it for best practice.
var state = g_form.getValue("state");
if( state != '6' || state != '7'){ // when state is resolved or closed
return;
}
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', g_form.getUniqueValue());
gr.addQuery('name', 'task');
gr.addQuery('element', 'work_notes');
gr.orderByDesc('sys_created_on');
gr.setLimit(1);
gr.query();
if (gr.next()) {
//Store last comment in variable
var lastComment = gr.value.toString();
alert(lastComment);
g_form.setValue('close_notes', lastComment);
}
}
Regards,
Souren