Skip to content

Commit

Permalink
CreateEmailHtmlBody fix false values (#32712)
Browse files Browse the repository at this point in the history
* CreateEmailHtmlBody fix false values

* RN
  • Loading branch information
JasBeilin authored Feb 5, 2024
1 parent 55ab6e7 commit e29c886
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Packs/CommonScripts/ReleaseNotes/1_13_34.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Scripts

##### CreateEmailHtmlBody

- Fixed an issue where fields with false values was not being copied correctly.
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,33 @@ while (found = reg.exec(html)) {
var path = found[1];

if (path.indexOf('incident.labels.') === 0) {
logDebug("Field " + path + " is handled as label.")
map[path] = getLabel(incidents[0], path);

} else if (path.indexOf('incident.') === 0) {
map[path] = dq({'incident': incidents[0]}, path);
// check if this path is actually in custom fields
if (!map[path]) {
// check if this path is actually in custom fields (not found directly under incident)
if (map[path] === null) {
logDebug("Field " + path + " is either custom or null. Handling as custom.")
var customFieldPath = path.replace('incident.', 'incident.CustomFields.');
map[path] = dq({'incident': incidents[0]}, customFieldPath);
}
} else if (path.indexOf('object.') === 0) {
logDebug("Field " + path + " is part of object.")

var obj = (typeof args.object === 'string') ? JSON.parse(args.object) : args.object;
map[path] = dq({'object': obj}, path);
} else {
map[path] = dq(invContext, path);
}
}
logDebug("Field value fetched: " + map[path])

// replacing all placeholders with values
for (var path in map) {
// if value found replace. Otherwise will leave placeholder
if (map[path]) {
// if value is found - replace. Otherwise will leave placeholder.
if (map[path] !== null) {
logDebug("Replacing value in " + path + " to " + map[path])
html = html.replaceAll('${' + path + '}', map[path]);
} else if (args.removeNotFound === 'yes') {
html = html.replaceAll('${' + path + '}', '');
Expand Down
2 changes: 1 addition & 1 deletion Packs/CommonScripts/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Common Scripts",
"description": "Frequently used scripts pack.",
"support": "xsoar",
"currentVersion": "1.13.33",
"currentVersion": "1.13.34",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit e29c886

Please sign in to comment.