How to insert text of textarea on Service Portal into a table record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2018 07:52 AM
I have created a textarea on Service Portal to retrieve rejection comments whenever any user rejects any approval.. i want to copy the rejection comments on approval table activity log. I am new to Service Portal please guide how to work on this requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2018 08:32 AM
Update those comments to Worknotes of the approval table then it automatically shown in the Activity Log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2018 11:40 PM
Hi Pallavi,
You can retrieve the comments on approval activity log from sys_journal_field table. In service portal, in Server script you have to write the following code, if the approval gets rejected :
var gr= new GlideRecord('sys_journal_field');
gr.addQuery('element_id','<sys_id of the rejected approval>');
gr.query();
while(gr1.next()){
data.comment=gr1.getValue('value'); // push approval comment in the data object
}
In the HTML , you need to bind the textarea element with data.comment as follows:
<textarea ng-model="data.comment"></textarea>
Hope it helps!
Regards,
Karishma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2018 12:47 AM
Have a doubt.. here you have created a glide object-'gr' then what is 'gr1' in if statement? Is it a typo?
Also i want to push textarea comment on approval worknotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2018 02:35 AM
hi pallavi,
Yes sorry that was a typo. And About the pushing the text area into worknotes you have to do as follows:
in HTML :
add ng-change which will call that specified function in client script.
<textarea ng-model="data.comment" ng-change="c.update()"></textarea>
In client script:
define the function that we will be calling from HTML i.e. c.update()
function(spUtil) {
/* widget controller */
var c = this;
c.update=function(){
c.server.get({
action:'update',
sys_id:c.data.approval[0].sys_id,
comment:c.data.approval[0].value
}).then(function(response){
spUtil.addInfoMessage("your record has beeen updated")
});
}
In Server Script:
In the previous server script you can add the below code:
if(input.action=="update"){
var gr2= new GlideRecord('sys_journal_field');
gr2.get(input.sys_id);
gr2.setValue('value',input.comment);
gr2.update();
}
}
Hope it helps.