Unique Values for Records (tables)Unique Values for Records (tables)RE: Unique Values for Records (tables)Mehmet Albayrakhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3268992015-06-22T11:44:30Z2015-06-22T11:39:31ZDear Fadi,<br /><br />Thank you for your question. To solve your problem use can use the event listener called "AfterEditAttributeValue". If you trigger this event if the record content if editted and compare the values of the column, you are able to set conditions (e.g. uniqueness). Please find attached an example library with an initial solution where the folllowing AdoScript code is integrated in the 'External coupling'-library attribute.<br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "AfterEditAttributeValue" {<br /><span class="code-lines"> 2</span>#Save the predefined parameters of the event<br /><span class="code-lines"> 3</span> SET id_ModelId: (modelid)SET id_InstId: (instid)<br /><span class="code-lines"> 4</span> SET id_AttrId: (attrid)CC "Core" <br /><span class="code-lines"> 5</span><br /><span class="code-lines"> 6</span>#Trigger the event only if the Table attribute is editted<br /><span class="code-lines"> 7</span> GET_CLASS_ID classname:"A"<br /><span class="code-lines"> 8</span> CC "Core" GET_ATTR_ID classid: (classid) attrname:"Table"SET nTableAttrId: (attrid)<br /><span class="code-lines"> 9</span> IF (nTableAttrId=id_AttrId) { <br /><span class="code-lines">10</span>#Get all row ids and save them in a list <br /><span class="code-lines">11</span> CC "Core" GET_ALL_REC_ATTR_ROW_IDS objid: (id_InstId) attrid: (id_AttrId) <br /><span class="code-lines">12</span> SET sRowids: (rowids)<br /><span class="code-lines">13</span>#Compare attribute values of the attribute "Value"<br /><span class="code-lines">14</span> FOR i in: (sRowids) { <br /><span class="code-lines">15</span> CC "Core" GET_ATTR_VAL objid: (VAL i) attrname:"Value" <br /><span class="code-lines">16</span> SET nVal1: (val) <br /><span class="code-lines">17</span> SET sRowCompare: (tokdiff(sRowids,i)) <br /><span class="code-lines">18</span> FOR j in: (sRowCompare) { <br /><span class="code-lines">19</span> CC "Core" GET_ATTR_VAL objid: (VAL j) attrname:"Value" <br /><span class="code-lines">20</span> SET nVal2: (val) <br /><span class="code-lines">21</span> IF (nVal1=nVal2) { <br /><span class="code-lines">22</span>#If the values are equal then give a warning. <br /><span class="code-lines">23</span> CC "AdoScript" ERRORBOX "Not Allowed!!!" <br /><span class="code-lines">24</span> } <br /><span class="code-lines">25</span> } <br /><span class="code-lines">26</span> SET sRowids: (tokdiff(sRowids,i)) <br /><span class="code-lines">27</span> }<br /><span class="code-lines">28</span> }<br /><span class="code-lines">29</span>}<br /></div>Mehmet Albayrak2015-06-22T11:39:31ZUnique Values for Records (tables)Fadi Al Machothttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3266382015-06-22T10:15:26Z2015-06-22T10:15:26ZHow can we define the attributes (columns) of a specific record to be unique, For example in my case the user should not be able to add 2 similar values of the attribute „Name“ in the record (table) „Attributes“ .Fadi Al Machot2015-06-22T10:15:26Z