4 Replies Latest reply on Jan 10, 2014 1:44 AM by Fabian Schmidt

    Updating a table through an automatic action while preventing duplicate entries

    Apprentice

      Hello LANDesk community,

       

      I'm currently working on a window where people will be adding records to a table in a different module that may already contain the records. That's to say, they will be selecting an item from a source dropdown, which will copy to a table on the local object, which then pushes the records back to the original table using runtime values on an automatic object.

       

      I need my object to push the records on to the original table when new values are entered, but when existing values are entered, I need it to refrain from duplicating the record.

       

      How do I prevent duplicate entries from being added to that table?

        • 1. Re: Updating a table through an automatic action while preventing duplicate entries
          Stu McNeill Employee

          Hi,

           

          Can I ask what scenario/business process you're trying to work with here?  I'm not sure I fully understand what you're trying to achieve.

           

          Thanks

          • 2. Re: Updating a table through an automatic action while preventing duplicate entries
            Fabian Schmidt Expert

            The only scenario I could think of how to check for a duplicate entry is a calculation.

             

            For example:

            import System
            static def GetAttributeValue(Request):
                      DuplicateCheck = Request._ReferenceList._Title
                      RefListEntry = Request.GetNamedObject("ConfigItem.CI", DuplicateCheck)
                      if RefListEntry != null:
                                return true
                      return false
            
            

             

            No if you have a this within a precondition followed by an automatic action you can move your process to a different status.

            Duplicate Check.png

             

            Now the second precondition checks again, that it is a duplicate and the properties "default action" and "autoprompt" for the manual action "Change List Entry" are set to true than, the window defined for the action will be displayed automatically.

             

            Just an idea. I have realised this for one of my customers.

            The Check the Request Title, if there is a valid domain name entered which dosn't already exist, for examle xyz.abc.com.

            If now the .abc.com is missing, or a subdomain CI with the same title already exists the requesting user has to correct his entered data.

            If the Duplicate Check dosn't return any value I create a new Subdomain with the title xyz.abc.com

             

            Regards

            Fabian

            • 3. Re: Updating a table through an automatic action while preventing duplicate entries
              Apprentice

              Hi schmiddi,

               

              I think what you posted is pretty much exactly what I will need. I do have a few questions though if you don't mind.

               

              1.) Is the calculation you posted entered on the first precondition called Duplicate Check?

              2.) IF so, can you post the Precondition logic? (Example: Condition, Value Type, Value)

               

              If I understand the logic correctly (bear with me, I'm still new to programming) then you've defined two values here.

              DuplicateCheck, which is the field you want to check for a value and

              RefListEntry, which is a combination of DuplicateCheck and "ConfigItem.CI"

               

              3.) Is GetNamedObject a function within Boo?

              4.) What exactly is "ConfigItem.CI" in your statement and how does it relate to the problem?

               

              I know that these are somewhat big questions, but before I apply your fix to my problem, I think I have to figure these things out.

               

              Best,

              Chad.

              • 4. Re: Updating a table through an automatic action while preventing duplicate entries
                Fabian Schmidt Expert

                Hi csimpson,

                 

                so to your questions:

                1) Yes the calc is within the precondition AND the decision named "Duplicate Check"

                2) The Condition is Calculation, then my calcuation, Comparsion is equal to, Value true.

                 

                Duplicate Check is my variable to save the title of the selected reference list

                RefListEntry chekcs in my example if there is already a CI with the same title is it is selected by the user in dere refernece list.

                 

                3) Yes, this is a Boo function within Service Desk

                4) ConfigItem.CI is the database table I check in my example. You could also use any other object, for example System.Group or whatever. My customer is doing a duplicate Check on CIs, so he can identify if the name of a CI enterd in a string field already exists.

                 

                If you have any more question just post them.

                 

                Greets Fabian

                1 of 1 people found this helpful