Skip to Content
Author's profile photo Stefan Hagen

Script for a node duplicate check

A while ago I wrote a very short ABSL script which works very well and many people do not know why.

The goal for it was a duplicate check on a node. Imagine you have a BO with an Accounts node. Now you add Accounts to this node, but would like to prevent an Account to be added twice.

Put this into the AfterModify of the node:

// Check double accounts in list

foreach(var entry in this.ToRoot.Accounts) {

       if(entry.ID == this.ID && this != entry) {

             raise MyMessage.Create(“E”, “Account can only be added once.”);



The interesting part is the if statement in the loop where it checks if there is already an entry with the same as the current ID. However, the new node entry is already in the buffer and therefore in the list. How do you know if you found the current one (which is ok) or a duplicate one (which is not ok)?

The magic is here: “this != entry” which compares the node IDs of the currently created entry with the node IDs in the loop. If these are different, you found the duplicate.

So keep in mind that “this” is also just a UUID which can sometimes become handy for usecases like this.

Best Regards,


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Horst Schaude
      Horst Schaude

      Nice ๐Ÿ˜†

      Author's profile photo Vinodkumar Kommineni
      Vinodkumar Kommineni

      Good trick to know ๐Ÿ™‚

      Author's profile photo Former Member
      Former Member


      Hi Stefan,


      I want to prevent creating Duplicate customer .

      Please help me on this.

      Please find the scn linkร

      Thanks & Regards,