How to get the ID of the deleted Reference modelsHow to get the ID of the deleted Reference modelsRE: How to get the ID of the deleted Reference modelsMehmet Albayrakhttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3578782015-08-17T13:17:11Z2015-08-17T12:58:09ZDear Fadi,<br />Thank you for your question. To realize your scenario you have to compare two lists of target object ids: <br /><br />1) The target object id list before deleting<br />2) The target object id list after deleting<br /><br />In order to receive these list of ids you have to parse the old and the new attribute value of "Participating". Please find below the example that delivers you the target object id of the deleted interref. Which you can also find in the attached AdoScript file.<br /><br /><br /><div class="code"><span class="code-lines"> 1</span>ON_EVENT "SetAttributeValue" {<br /><span class="code-lines"> 2</span><br /><span class="code-lines"> 3</span>SETG nCurrentObjID: (instid)<br /><span class="code-lines"> 4</span>SETG oOldValue: (oldval)<br /><span class="code-lines"> 5</span>SETG nCurrentModelID: (modelid)<br /><span class="code-lines"> 6</span>SETG nCurrentAttrID: (attrid)<br /><span class="code-lines"> 7</span><br /><span class="code-lines"> 8</span>CC "Core" GET_CLASS_ID objid: (nCurrentObjID)<br /><span class="code-lines"> 9</span>SET nCurrentClassID: (classid) <br /><span class="code-lines">10</span>CC "Core" GET_ATTR_ID classid: (nCurrentClassID) attrname: "Participating"<br /><span class="code-lines">11</span>SET nParticipatingAttrID: (attrid)<br /><span class="code-lines">12</span># only continue if the correct ID<br /><span class="code-lines">13</span>IF (nCurrentAttrID = nParticipatingAttrID) { <br /><span class="code-lines">14</span> CC "Core" GET_ATTR_VAL objid: (nCurrentObjID) attrname: ("Participating") <br /><span class="code-lines">15</span> SET oNewValue: (val) <br /><span class="code-lines">16</span> IF (LEN oOldValue > LEN oNewValue) { <br /><span class="code-lines">17</span><br /><span class="code-lines">18</span> ##########################################<br /><span class="code-lines">19</span> # Get target Ids of the deleted InterRefs#<br /><span class="code-lines">20</span> ##########################################<br /><span class="code-lines">21</span><br /><span class="code-lines">22</span> # Get list of the InterRefs of the NEW Attribute Value with parsing the InterRefs after calling all outgoing InterRefs<br /><span class="code-lines">23</span> CC "Core" GET_ALL_INTERREFS_OF_ATTR objid: (id_InstId) attrid: (nCurrentAttrID)<br /><span class="code-lines">24</span> SET s_IntReftext: (reftext)<br /><span class="code-lines">25</span> SET listIds:""<br /><span class="code-lines">26</span> FOR i in: (s_IntReftext) sep:"\n" {<br /><span class="code-lines">27</span> SET parseExp: (i)<br /><span class="code-lines">28</span> IF (parseExp!="") {<br /><span class="code-lines">29</span> # Search for target object id with parsing a LEO expression<br /><span class="code-lines">30</span> LEO parse: (parseExp) get-str-value:str_ToObjId:"tobjid"<br /><span class="code-lines">31</span> # If you want to obtain target modelid than enter "tmodelid" instead of "tobjid"<br /><span class="code-lines">32</span> # Save in a list<br /><span class="code-lines">33</span> SET listIds: (tokunion(listIds,str_ToObjId))<br /><span class="code-lines">34</span> }<br /><span class="code-lines">35</span> }<br /><span class="code-lines">36</span><br /><span class="code-lines">37</span> # Get list of the InterRefs of the OLD Attribute Value with parsing the attribute value<br /><span class="code-lines">38</span> SET olistIds:""<br /><span class="code-lines">39</span> FOR j in: (oOldValue) sep:"\n" {<br /><span class="code-lines">40</span> SET oparseExp: (j)<br /><span class="code-lines">41</span> IF (oparseExp !="") {<br /><span class="code-lines">42</span><br /><span class="code-lines">43</span> #Obtain the several values of the Interref by LEO parse<br /><span class="code-lines">44</span> LEO parse: (oparseExp) get-str-value:str_oToObjName:"i"<br /><span class="code-lines">45</span> LEO parse: (oparseExp) get-str-value:str_oToModelType:"mt"<br /><span class="code-lines">46</span> LEO parse: (oparseExp) get-str-value:str_oToModel:"m"<br /><span class="code-lines">47</span> LEO parse: (oparseExp) get-str-value:str_oToClassId:"c"}<br /><span class="code-lines">48</span><br /><span class="code-lines">49</span> #Get target object ids and save them in a list<br /><span class="code-lines">50</span> CC "Core" GET_MODEL_ID modelname: (str_oToModel) modeltype: (str_oToModelType)<br /><span class="code-lines">51</span> SET nReferencedModelId: (modelid)<br /><span class="code-lines">52</span> CC "Core" GET_CLASS_ID classname: (str_oToClassId)<br /><span class="code-lines">53</span> SET nReferencedClassId: (classid)<br /><span class="code-lines">54</span> CC "Core" GET_OBJ_ID modelid: (nReferencedModelId) classid: (nReferencedClassId) objname: (str_oToObjName)<br /><span class="code-lines">55</span> SET noToObjId: (objid)<br /><span class="code-lines">56</span> SET olistIds: (tokunion(olistIds,STR noToObjId))<br /><span class="code-lines">57</span> }<br /><span class="code-lines">58</span><br /><span class="code-lines">59</span> # Compare and make the difference between the old and the new value<br /><span class="code-lines">60</span> SET l_DeletedTargetIdsOfInterRefs: (tokdiff(olistIds,listIds))<br /><span class="code-lines">61</span> CC "AdoScript" INFOBOX (l_DeletedTargetIdsOfInterRefs)<br /><span class="code-lines">62</span> }<br /><span class="code-lines">63</span>}<br /><span class="code-lines">64</span>}<br /></div><br />As the InterRef "Participating" is an object reference the example delivers the deleted objids and not the modelids. But the principle of the implementation would be the same.<br /><br />.Mehmet Albayrak2015-08-17T12:58:09ZHow to get the ID of the deleted Reference modelsFadi Al Machothttps://www.adoxx.org/live/c/message_boards/find_message?p_l_id=&messageId=3575422015-08-17T08:33:33Z2015-08-17T08:29:02ZIf we have an attribute of datatype "Interref " called "Participating", how can we get the Ids of the selected reference models when we have a set of them, e.g., <br />The current script for the event <em><strong>SetAttributeValue</strong></em><strong><em> </em></strong> idetifies if the user did delete a model or did add a new model, then I would like to get the Id of the deleted ones:<br /> <br /> <br />SET nCurrentObjID: (instid)<br />SET oOldValue: (oldval)<br />SET nCurrentModelID: (modelid)<br />SET nCurrentAttrID: (attrid)<br />CC "Core" GET_CLASS_ID objid: (nCurrentObjID)<br />SET nCurrentClassID: (classid)<br /> <br />CC "Core" GET_ATTR_ID classid: (nCurrentClassID) attrname: "Participating"<br />SET nParticipatingAttrID: (attrid)<br /># only continue if the correct ID<br />IF (nCurrentAttrID = nParticipatingAttrID) {<br /> CC "Core" GET_ATTR_VAL objid: (nCurrentObjID) attrname: ("Participating")<br /> SET oNewValue: (val)<br /> IF (LEN oOldValue > LEN oNewValue) {<br /> # this is a removal<br /><u><em><strong># Get Ids of the deleted ones</strong></em></u><br /> }<br />}<br />}Fadi Al Machot2015-08-17T08:29:02Z