How to access and use TrackVia's API or Application Scripts?

Before/After Delete App Scripts: Do these work?

It seems the before/after delete app scripts don't work the same way as the insert/update ones, but not 100% sure.

I'm trying to prevent the user from deleting a parent record that has any child records from a certain table attached to it.

The script should be pretty simple. On the parent table:

Before Delete

List childRecords = getChildren "TableName", "FieldName"
throw new RuntimeException

This hasn't worked whenever I've tried it. However I structure it, a Delete app script can't seem to find child records. I'm I misunderstanding something here?


1 vote
Sign in
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Anonymous shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • Anonymous commented  ·   ·  Flag as inappropriate

    Hey Alex,
    Thanks for the quick response! The order-of-operations issue makes sense now.
    Appreciate the solutions you've provided, both of these look like fantastic options.

  • Alex commented  ·   ·  Flag as inappropriate

    Hi Markwood,

    Unfortunately this process is not possible due to the order of operations within the system. In this case, when the record is marked for deletion by the system, the first thing it does is remove the relationship link to the children. This means that the script does not find any child records in your List.

    There are two possible alternatives for this instead:

    1) Add a checkbox field to the parent that the user must check before deleting the parent. Checking this box can fire the app script to delete the child records first. This is a multistep process for the user, but will help ensure children are deleted before the parent (or assigned to a different parent depending on the use case. This would run BEFORE UDPATE.

    2) Still using a BEFORE DELETE trigger, you could use a triggered field that counts the number of children linked to the record. The script can then reference this count and if the count is greater than zero, throw the RuntimeException error to prevent the user from deleting the parent. Our example script is below:

    Integer childcCount = currentValues["Child Count"] as Integer
    if((childcCount) && (childcCount > 0)) {
    throw new RuntimeException ("Blocked!")

    The caveat to this is there is no orange error displayed on the screen. The deletion is simply not carried out and the user remains on the form. This is a known issue with this type of script that we are looking to resolve.



Feedback and Knowledge Base