How to get the source item properties in the related item onafteradd event?

hi All,

I have an type(source item) called A.

A has relationship called B, which relates A to C(related item)

I wrote a VB server event and in related item(C) onafteradd to execute
I want to get the properties of the source item before the relationship item is saved (onafteradd) and make a judgment with the properties of the relationship item.

my question is:

I'm trying to find the source_id of the relationship(B) to get the source item(A).
But I can't find the source id of the relationship because it's a new relationship that hasn't been created yet.

Dim B_relid As string = Me.getProperty("id")
Dim B as Item = Me.newItem("B","get")
B = B.apply()

Dim A_id as String = B.getproperty("source_id")            
Dim A As Item = myInnovator.GetItemById("A", A_id)     ' error because A_id is empty

Dim A1 As string =A.getProperty("a1") 

Can anyone tell me the code how to get the source item property using VB?

Thank you!

  • Hi,

    which event type do you use? You mentioned onAfterAdd, 

    When you use onBeforeAdd, you have to use an additional query to get the information regarding related items (or source items).
    Before storing the item, you don´t have information regarding source_id/related_id, but you should already have the relationship id itself.

    Would it be possible for you do use a js Method for your validation instead? Cause then you could use parent.item.

    Edit: Code sample showed something else.