- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2022 03:34 AM
I want to load data via email attachment, and create an incident at the same time while loading data, but how to associate the new incident record with loaded data? Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 09:31 PM
Hi,
can you print what came in source.sys_import_set.number?
try this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var gr = new GlideRecord("incident");
gr.initialize();
gr.short_description = import_set.number;
gr.insert();
})(source, map, log, target);
Similarly update the onAfter
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var gr = new GlideRecord("incident");
gr.addQuery("short_description", "LIKE", import_set.number);
gr.query();
if (gr.next()) {
target.fieldName = gr.getUniqueValue(); // if target field is reference to incident
// OR
// target.fieldName = gr.number; // if target field is string
}
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2022 03:54 AM
Please mark my response as correct and close the thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2022 08:10 PM
or is it possible for putting the loaded data to the new created incident's related list?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2022 08:26 PM
Hi,
I already shared the logic.
in the inbound first create specific incident; then use onAfter transform script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2025 10:46 PM
Hi Angkur,
I was following the link you shared, however in my end, I can't for some reason copy the attachment from the inbound email to the Data Source.
Hence I cannot import my attachment properly, it is always blank.
Regards,
Jhuls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2022 08:37 PM
I write the short description with email.text, but can you tell me in the transform map onAfter script, how to find the new created incident? thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2022 09:17 PM
Hi,
like this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var gr = new GlideRecord("incident");
gr.addQuery("short_description", "your text");
gr.query();
if (gr.next()) {
target.fieldName = gr.getUniqueValue(); // if target field is reference to incident
// OR
// target.fieldName = gr.number; // if target field is string
}
})(source, map, log, target);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader