- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 02:13 AM
Hi all,
I have this strange issue that every time I use my record producer to create records, it will always create an empty record.
The other records also get created but with an error of duplicate key because of it.
I can't seem to figure out where it comes from, and I wonder if anybody could have some tips on tracking where this comes from.
this is a record that always gets created
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 05:51 AM
Hello,
An empty field will be always created because there is no mapping except the script you have shared.
So I propose this solution for your requirement :
Create a business rule that delete the empty record.
For my case I create a record producer that points to the incident table :
Businnes rule :
Here the test when business rule is inactive :
as you can see there is two records : The extra empty record.
Now after activating the business rule :
if it meets your needs, change only the conditions that allow to identify well the empty record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 03:51 AM
Can you share the script here?
What happens if you don't use script?
are you having some other fields which are mapped?
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-19-2022 03:56 AM
here is the script. Without the script, it won't add the new records that are created.
these are the only fields used
(function() {
var rowsInt = producer.stats.getRowCount();
for(var i = 0; i < rowsInt; i++) {
var grStat = new GlideRecord('x_pl4_snps_fact');
grStat.initialize();
grStat.setValue('date', producer.registration_date);
grStat.setValue('competency', producer.stats.getRow(i).competency);
grStat.setValue('metric', producer.stats.getRow(i).metric);
grStat.setValue('current', producer.stats.getRow(i).current);
grStat.insert();
}
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 07:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 02:41 AM
Hi,
Is it always for this record producer or all record producers in the instance?
check this out
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-19-2022 03:44 AM
only this particular record producer