- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 06:17 AM
Hi All,
I want to remove everything after new line from custom field.
I am using This field transform script.
answer = (function transformEntry(source) {
var GR = source.u_description.toString();
var index = GR.indexOf("Fault Offset:");
var event = GR.indexOf("Event Details :");
if (index != -1) {
gs.log('Inside loop');
var offset = GR.substring(index, index + 22);
gs.log('fault =' + index);
return source.u_short_description.toString() + ' ' + offset;
} else {
gs.log('event details found');
gs.log('Event details =' + event);
var edetails = GR.substring(event, event + 50);
return source.u_short_description.toString() + ' ' + edetails;
}
})(source);
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 09:16 PM
Try the below script, I am considering you are receiving value in edetails field :
var edetails = GR.substring(event, event + 50);
edetails = edetails.split("\n") [0] ;
This will remove everything after new line. If you do not have new line it will reurn your text and if it has new line it will remove everything from first new line
I hope this help.
Please mark this helpful if this helps and Accept the solution if this solves your issue.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 10:04 PM
Hi @kamlesh kjmar thank you, that worked for me.
@AnubhavRitolia thank you, Sorry i did not do great job explaining.