- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We have an emailed CSV attachment that we want to load and map to our environment but the first three /r/n prevent us from being able to load the data in.
Has anyone made a custom flow designer action or script that can remove the first X lines from a CSV attachment inbound?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RyanPSchneider,
Approach: Flow Designer Custom Action to Strip First X Lines
Inputs:
attachmentSysId → sys_id of the CSV attachment
linesToSkip → number of lines to remove (e.g., 3)
Outputs:
cleanedCSV → CSV string with header/junk lines removed
Server-side Script (example):
(function execute(inputs, outputs) {
var gsa = new GlideSysAttachment();
var bytes = gsa.getBytes(inputs.attachmentSysId);
var content = Packages.java.lang.String(bytes, "UTF-8"); // convert to string
// Split into lines, handle both \r\n and \n
var lines = content.split(/\r?\n/);
// Remove first X lines
var cleaned = lines.slice(parseInt(inputs.linesToSkip, 10)).join("\n");
// Return cleaned CSV as output
outputs.cleanedCSV = cleaned;
})(inputs, outputs);
🔄 How to Use in a Flow
Flow trigger → e.g. Inbound Email with attachment.
Custom Action (above) → input = attachment sys_id, linesToSkip = 3.
Use cleanedCSV output in your next step:
Write back to a new attachment, or
Parse directly with your CSV parser/import logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @RyanPSchneider ,
Good to know the solution worked and you thought of helping others as well.