Unique Fields combination Trigger with one empty field - Forum - Rollbase - Progress Community

Unique Fields combination Trigger with one empty field

 Forum

Unique Fields combination Trigger with one empty field

This question is not answered

Hi,

I was wondering what behavior should be expected from unique field combination trigger, in the case one of the fields is empty.

Basically, I am using this trigger to check the uniqueness of two fields A and B combination. A is lookup field from a hierarchy relationship, so it is the parent record of the current one, and B is an integer. 

I am having some strange behavior when the field A is empty (no parent), ie: sometimes it works, sometimes not !

Can you clarify me on this ? Is this trigger supposed to do the checks normally even when one of the fields is empty ?

Thank you

Mery

All Replies
  • Hi Mery,
    I did my best trying to reproduce cases you wrote about.
    Generally speaking, I failed.
    I found a couple rather weird scenario which probably are not your case. Nevertheless:
    1.
    Suppose you deleted an object and created another one with the same combination of unique fields.
    Then you decided to restore the one you deleted. Due to a Rollbase bug you may do it. So in this case you would have two objects with the same set of unique field values.
    Now if you delete one of them and create a new one then you would get an error because actually there already is an object with those fields.
    2.
    Suppose you deleted an object with a child(s). If you deleted it the child records would still have the parent id.
    So if you try to create a new record with the parent id of the deleted object you would get an error message because some records already have this parent (despite the parent object was deleted). But it is also very unlikely because can't do it using UI lookup feature but have to type the parent id into the input field.
     
    Speaking about 0 value in the parent field in the DB, I did not find any possibility to do that.
     
    So it is very important if you could provide more details when one of those problems happens again.
     
    Thank you,
    Yuriy
     
    From: Meryk [mailto:bounce-Meryk@community.progress.com]
    Sent: Friday, July 10, 2015 5:15 AM
    To: TU.Rollbase@community.progress.com
    Subject: RE: [Technical Users - Rollbase] Unique Fields combination Trigger with one empty field
     
    Reply by Meryk

    Hi again Yuriy,

    Just checked something and this might be interesting for you to consider :

    For a Top Level Record, i.e one with no parent, in the Database, the field parent is 'NULL'. And sometimes, after updating the record, it goes to 0, but not always.

    We had this issue sometime back, and worked around it. But it seems that when a record is created with an "empty" field in Rollbase, it is first created with a value "NULL" in the database, then only after updating it, it goes to "empty".

    We tried to reproduce this behavior for our Hierarchy relationship, but as I said, it is 'NULL' first, then goes to '0' or stays 'NULL'.

    Is that something you were aware of ? We think it has something to do with the issue we are facing now with the unique field combination trigger.

    Thank you

    Mery

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • Hi Yuriy,

    Thank you for the reply.

    1- Ok for the first case, but in my case, I was getting that bug without even restoring the deleted object. Let me try to reproduce it again and will give you more details hopefully.

    2- Ok for this case too. I understand. Fortunately we do not have to deal with this in our case, because we are not allowing deleting an Item that has children.

    For the 0 value, we could not really reproduce the scenario of obtaining 0 in the parent field.

    But what we did, is attaching this item (with 0 value in the parent field) to a parent, then detaching it, and then this value went back to NULL. So this is how we fixed it. But sorry we could not go back to how we get that 0 from the beginning..

    Tahnk you

    Mery

  • Hi Yuriy,

    I just have another scenario to suggest, maybe this is another case of the bug:

    Let's say we have two records 1 and 2. Record 1 has field combination (x,y) and Record 2 has field combination (x,z).

    If I go to record 2 and update the second field from value 'z' to value 'y' , it is allowing me to do so, which shouldn't be allowed again. Now I have both  Record 1 and Record 2 with the same combination (x,y).

    Can you please try this case as well? And confirm what behavior it is having in this specific case please?

    Only thing I can see from the trigger debug, is that the unique field combination is just not running, but it should as the timing is Before Create and Before Update.

    Thank you

    Mery