Business rule help - Stop insert on conditon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 07:41 AM
Hi all, we have a custom table which is pulling in asset information, however we dont want IPhone records to create. I've tried the below business rule but having no joy, anyone know where I'm going wrong?
(function executeRule(current, previous /*null when async*/ ) {
var device = current.u_device_type;
if (device == "IPhone") {
current.setAbort(true);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 07:48 AM
Hi @Andrew18
It's current.setAbortAction(true);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 07:59 AM
Hi, thanks for coming back to me, I've tried this function before no joy sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 08:07 AM
Hi @Andrew18
Use before -insert business rule
You can use filter condition in "when to run" as Device type is Iphone
and in "Action" section select setAbort to true
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 08:15 AM
Thanks everyone...
I fixed it! I was missing the current.operation() == 'insert';
(function executeRule(current, previous /*null when async*/ ) {
if (current.operation() == 'insert' && current.u_device_type == "iPhone") {
current.setAbortAction(true);
}
})(current, previous);