Adding links to a m:n relationship from as BPM

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esendino
    Senior Member
    • May 2019
    • 163

    #1

    Adding links to a m:n relationship from as BPM

    Hello.

    I'm using version 8.4.

    I need to add a many-to-many link and I'm having trouble adding it from a bpm

    The tables to be related are:
    TSMovimiento
    FCHecho
    Neither of these entities has a formula to be executed before saving, nor any API requests for formulas, nor any Hook.

    And this is the relationship definition:
    Entity: TS Movimiento
    Link: tSMovimientos
    Type: many-to-many
    Foreign Link: fCHechos
    Foreign Entity: FCHecho

    I have a BPM with TSMovimiento as the target entity. There's a script task with this code:

    $prFCHechoAddId = '69629f1f76bd448aa'; //example to be added. Yes, it exists
    $prFCHechosAddIds = list($prFCHechoAddId);

    // To get the data before the relationship
    $prTSMovObjetoAnte = record\fetch('TSMovimiento', $prTSMovimientoId); // $prTSMovimientoId is the current record

    $prRelacion = record\relate('TSMovimiento',
    $prTSMovimientoId,
    'fCHechos',
    $prFCHechoAddId);

    // To get the data after
    $prTSMovObjetoPost = record\fetch('TSMovimiento', $prTSMovimientoId);

    Execution Results

    $prRelacion: true. This means it worked correctly.

    In $prTSMovObjetoAnte we see "fCHechosIds": [ "6953899170b9d0ad2"] // The process starts with just one FCHecho related
    and in
    $prTSMovObjetoPos we see "fCHechosIds": [ "69629f1f76bd448aa", "6953899170b9d0ad2"] // The process ends with two FCHecho related

    That is, the link was added correctly.

    However, when, after that, I see the TSMovimiento the added link has disappeared, only remains the original one.

    And if I run it again, it repeats the same cycle. It adds the link and then it disappears

    As I mentioned, there are no hooks nor Formula for these entities.

    Any ideas what might be happening? How can I trace what is happening?
Working...