Topic
  • 4 replies
  • Latest Post - ‏2013-05-16T09:02:55Z by raj_kgdr
raj_kgdr
raj_kgdr
63 Posts

Pinned topic remove button in the parent record doesn't remove the child records at the backend

‏2013-05-10T08:01:08Z |

Dear SMEs.

I notice that when you hit the remove button in the parent record to remove the child records associated with it, the action removes the child records only from actual GUI, but apparently the child records still exists at the backend at the database level.

I saw something like the pre-action and the post-action hooks available with the "Remove" button. Is this the solution for this?

If yes how exactly can I make use of it. Should I place these in the Global scripts?

Would be great if someone helps me with a VB code as an example please.

 

Thanks,

Raj

  • Lumart
    Lumart
    87 Posts

    Re: remove button in the parent record doesn't remove the child records at the backend

    ‏2013-05-10T10:04:20Z  

    The Remove button is not intended to remove the children records from the backend database, but to remove the reference to them from the parent record.

    After they have been removed from the parent, you can physically remove them by means of a Delete action, provided that you have defined such an action.

    If you want to automatically remove them from the database after the removal of the reference, you can write a hook that runs in the notification of the action on the parent record.

  • raj_kgdr
    raj_kgdr
    63 Posts

    Re: remove button in the parent record doesn't remove the child records at the backend

    ‏2013-05-13T03:25:35Z  
    • Lumart
    • ‏2013-05-10T10:04:20Z

    The Remove button is not intended to remove the children records from the backend database, but to remove the reference to them from the parent record.

    After they have been removed from the parent, you can physically remove them by means of a Delete action, provided that you have defined such an action.

    If you want to automatically remove them from the database after the removal of the reference, you can write a hook that runs in the notification of the action on the parent record.

    Hi Lumart,

    Can you help me with an example please??

    Thanks

     

  • pdubovitsky
    pdubovitsky
    376 Posts

    Re: remove button in the parent record doesn't remove the child records at the backend

    ‏2013-05-13T11:03:45Z  
    • raj_kgdr
    • ‏2013-05-13T03:25:35Z

    Hi Lumart,

    Can you help me with an example please??

    Thanks

     

    Example that removes all children:

    my $children = $entity->GetFieldValue('Children_Field')->GetValueAsList();
    foreach my $child_id (@$children){
      my $child = $session->GetEntity('RecordTypeName', $child_id);
      $session->DeleteEntity($child, 'DeleteActionName');
    }

    Pavel

    Updated on 2013-05-13T11:06:27Z at 2013-05-13T11:06:27Z by pdubovitsky
  • raj_kgdr
    raj_kgdr
    63 Posts

    Re: remove button in the parent record doesn't remove the child records at the backend

    ‏2013-05-16T09:02:55Z  

    Example that removes all children:

    my $children = $entity->GetFieldValue('Children_Field')->GetValueAsList();
    foreach my $child_id (@$children){
      my $child = $session->GetEntity('RecordTypeName', $child_id);
      $session->DeleteEntity($child, 'DeleteActionName');
    }

    Pavel

    Hi Pavel,

    Thanks for your continued support everytime I post something.

    But would you be so kind to let me know if I can apply the above for a remove button, and if yes should I associate it with a pre-action or a post-action hook?

    And also does this pre-action or post-action hook reside in the Global folders?

     

    Cheers,

    Raj