Issue with Triggers for Attach Related Record vs Update Fiel

Posted by cohezive on 05-Mar-2015 14:04

I have a hierarchical relationship on Object A - essentially to establish a parent-child model.

I imported the object records and created triggers to establish the relationships.

When I use "Attach Related Record" from a child to the parent, the relationship shows up in a List View but (this is weird) not in the object view.  The parent record does show the child relationship in its object view.

The only way I can get it to show in both the List View and the Object View is to use an Update Field Value trigger for the Parent relationship field.  

The formulates in the triggers are identical and both return the same integer arrays.  

(Note this is in Private Cloud v3.1.3.0).

All Replies

Posted by Orchid Corpin on 05-Mar-2015 16:25

Hi cohezive,

Sorry I don't understand clearly the issue, if you can specify a screenshots it would better, this would help me investigate the issue as well.

Thank you.

-Orchid

Posted by cohezive on 05-Mar-2015 17:31

That's not possible without a lot of work since I've already changed the application.  So let's try this:

Create Object A with Name, Ref No,  and, Parent Ref No.  (Ref No must be unique).

Create a Hierarchical Relationship on A with "Parent A" and "Child A" - and add them to the New, View and Edit Pages.

Edit the "All Record View" to show the Parent in the Record List.

Write an After Create Trigger to "Attach Related Record" with the script finding the Parent record via query and returning an array containing the ID found to the Hierarchical Relationship.

Import records into A with the three fields - make sure the records are sorted according to Ref No.

Import should kick off the Run the After Create Trigger.

What you should see in the View is each record has the parent name in Record List.  However, when you go into the View Object Page, the field for the Parent relationship is empty.

After validating that - now create a replacement After Create Trigger to "Updated Field Value" using the same script as above.  The field to be updated is the Parent field in the relationship.   Repeat the View List and View Object and this time, it appears in both.  

If you still don't understand or cannot duplicate the issue, let me know and I'll work on screenshots.

Posted by Orchid Corpin on 09-Mar-2015 11:42

Hi,

1. I already created the two Object Ref No (Many) : Parent Ref No (Many). Is this the right cardinality in your setup?

2. I created a records e.g. Test Parent with 3 Test Ref no Attach to it.

I feel confused doing the statement below. Is trigger will be in the child obj? Do I have to query all parents regarless if there is a child or not then attach all these parent to current child record?

"Write an After Create Trigger to "Attach Related Record" with the script finding the Parent record via query and returning an array containing the ID found to the Hierarchical Relationship."

Regards,

Orchid

This thread is closed