Select to view content in your preferred language

Associations change detection: $originalFeature associations

151
0
03-11-2025 06:10 AM
Lucas_Goded
New Contributor

Hi, im trying to detect changes in associations between $feature and $originalFeature.

I tried doing this:

function difference(list1, list2) {
    var diff = [];
    for (var item in list1) {
        if (IndexOf(list2, item) == -1) { Push(diff, item) }
    }
    return diff
}

// Detectar si hay cambios en asociaciones de adjunto estructural
var asso = FeatureSetByAssociation($feature, "attached");
var original_asso = FeatureSetByAssociation($originalFeature, "attached");
 
// Obtener ids de las entidades asociadas
var ids = [];
for (var a in asso) { Push(ids, a.GLOBALID) }
var original_ids = [];
for (var oa in original_asso) { Push(original_ids, oa.GLOBALID) }
 
// Comparacion entre asociaciones
var new_asso = difference(ids, original_ids);
var del_asso = difference(original_ids, ids);
 
// Verificar cambios
if (Count(new_asso) == 0 && Count(del_asso) == 0) {
    // No se han producido cambios en los adjuntos estructurales
    return
}
 
But $originalFeature seems to return same assosiations as $feature, when the original feature has no associations yet. This attribute rule is set to insert, update, and is trying to detect changes in associations (attach) for doing other calculations.
Tags (1)
0 Kudos
0 Replies