Is it possible to define a combination of fields as unique in a table i.e. ID + Date + Email?
If so, what happens when an automation tries to Create Item into the table which will violate that - will if fail gracefully and continue to the next action, or cause an error and stop the automation from continuing to run?
Also, since the Create Item works by independently copying one field at a time, wouldn't it create some of the fields in the records, and then failing for the rest, but will leave an orphan record in the table?
To register for the forums, please contact your Digital-Clay representative.
Creating unique items using the database
-
ZevToledano
- Posts: 722
- Joined: Fri Apr 03, 2009 2:29 pm
Re: Creating unique items using the database
The only recommended way to ensure uniqueness is by using a Unique Index on the field via Custom Fields. Creating indexes on multiple fields is currently not supported but is planned for a future release. In the meantime, you should be able to simulate it by creating an automation that concatenates the values from all the relevant fields into a single field and then setting a unique index on that field.
Automation actions that fail add an error to the log and continue to the next action. This includes index violations.
The Create Item inner actions that set fields are actually special in that they are all run BEFORE the record is even saved. This was designed like this in order to avoid situations exactly like this one, where you need to set several required fields before the record can be saved. All other setfield actions (i.e. outside of a Create Item action) however run one at a time and update the record with every action.
This means that if you didn't set all the fields properly in the Create Item action, no record will be saved.
Automation actions that fail add an error to the log and continue to the next action. This includes index violations.
The Create Item inner actions that set fields are actually special in that they are all run BEFORE the record is even saved. This was designed like this in order to avoid situations exactly like this one, where you need to set several required fields before the record can be saved. All other setfield actions (i.e. outside of a Create Item action) however run one at a time and update the record with every action.
This means that if you didn't set all the fields properly in the Create Item action, no record will be saved.
Re: Creating unique items using the database
So how do I create a combination of both answers you gave?
If I create a new record, I need to - after completing the inner set fields inside the Create Item - first run an automation to create the unique field from a combination of more than one of the new fields, and have all that done inside an inner Create Item so that it will fail when it tries to add the record and finds that its not unique?
If I create a new record, I need to - after completing the inner set fields inside the Create Item - first run an automation to create the unique field from a combination of more than one of the new fields, and have all that done inside an inner Create Item so that it will fail when it tries to add the record and finds that its not unique?
-
ZevToledano
- Posts: 722
- Joined: Fri Apr 03, 2009 2:29 pm
Re: Creating unique items using the database
Not sure I understood that sentence... Just create a unique index and fill that field using a function that concatenates all the values, using a 'set field function' action inside the Create Item.
This should work as long as you don't have a record with a blank value for that field (two blanks violate the unique index). There is a possible issue here because of the way ClayCentral runs functions on unsaved items by using temporary records. If you see this doesn't work then create the concatenated value in a field in the original record, then copy it over to the Created record.
This should work as long as you don't have a record with a blank value for that field (two blanks violate the unique index). There is a possible issue here because of the way ClayCentral runs functions on unsaved items by using temporary records. If you see this doesn't work then create the concatenated value in a field in the original record, then copy it over to the Created record.