Forum Discussion

dkinsley's avatar
dkinsley
Creator II
6 years ago
Solved

Copy the related CR "product" text field value to the "product" text field on the CE form

Our CR and CE forms both have a "Product" text field. The originator of the CR enters the product number in the CR product field. I need that value to copy to the product text field on the CE whe...
  • Hello,

    There's a few options to consider for this. Based on your description, these suggestions will be made with the assumption that each CE will have one and only one related CR.

    The first option would be to handle this server-side. This easiest place to put this would be in an onAfterAdd server event on the a_CE_a_CR ItemType. Since this is a relationship between CE and CR, you would have references to both items in this server event. You can then look up what the product field of the related CR is and then do an edit on the parent CE to sync the values. This approach does not handle the case where the product field changes on the related CR after the relationship has already been added though.

    If you need to account for the product field on the CR changing, then you can instead use an onAfterAdd/onAfterUpdate event on the CR ItemType itself. This will be slightly more involved since you'll need to do another query inside of this event to get the CE that has a relationship to that CR.

    One other approach that would require some data model changes would be to use a foreign property. If there is indeed only one CR per CE, then you could remove the a_CE_a_CR relationship and instead just use an item property off of the CE ItemType that points to a CR. If you take this approach, you can use a foreign property to have a field on the parent CE that automatically shares its value with that of a property on the linked CR. 

    Chris


    Christopher Gillis

    Aras Labs Software Engineer