How to split work notes value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2019 02:02 PM
I have a work notes field on the incident table so I have to split it and store in the array and I can get the whole comment value in a particular array's index. I am doing this in the business rule
(function executeRule(current, previous /*null when async*/) {
var notes = current.work_notes.getJournalEntry(-1);
gs.addInfoMessage(notes);
var spl = [];
spl = notes.split('(Work notes)');
gs.addInfoMessage(spl[0]);
gs.addInfoMessage(spl[1]);
gs.addInfoMessage(spl[2]);
gs.addInfoMessage(spl[3]);
})(current, previous);
I get the output like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2019 05:58 PM
Hi,
Can you clarify what the requirement is here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2019 06:27 PM
I have a work notes field on an incident table so "var notes = current.work_notes.getJournalEntry(-1);" this lines bring all comments in a single string so I have separate all work notes activity in separate array index.
If I type arr[0];
o/p: 04/02/2019 01:59:37 PM - System Administrator Hari
If I type arr[1];
o/p: 04/02/2019 02:01:37 PM - System Administrator I am working on it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2019 08:11 PM
Hi,
Try this and let me know if it works !!!
(function executeRule(current, previous /*null when async*/) {
var notes = current.work_notes.getJournalEntry(-1);
gs.addInfoMessage(notes);
var spl = [];
spl = notes.replace(/\(Work notes\)/g,'').split("\n\n");
gs.addInfoMessage(spl[0]);
gs.addInfoMessage(spl[1]);
gs.addInfoMessage(spl[2]);
gs.addInfoMessage(spl[3]);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2019 02:01 AM
Do not have to use \n\n OOTB functionality