Forum Discussion

RB2023's avatar
RB2023
Ideator I
3 years ago
Solved

How to use a foreign property in a MAC policy?

Hi all,

I've tried to convert a foreign property to a string on a Document Item Type as foreign properties aren't compatible with MAC policies, but I'm not getting very far.

The current thinking is:

  1. Create foreign property "input"
  2. Create string property "output"
  3. Write server event OnBeforeAdd to get value of "input", and set value of "output" to the "input" value as a string
    1. something along these lines: Me.setProperty("output",Me.getProperty("input") As String)

Doesn't seem to be returning anything as the "output" property remains blank.

FYI, the foreign property in this instance is a property of created_by_id. Is it something to do with when the creation is actually being registered?

Your help's much appreciated!

Thanks,

RB

  • Something like this

    [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:04d1adfb-19f5-4c80-b133-83b069ca2c8b:type=text&text=Dim%20Inn%20As%20Innovator%20%3D%20Me.getInnovator%28%29%0AMe.SetProperty%28%22output%22%2C%20Inn.GetItemById%28%22User%22%2C%20Inn.GetUserID%28%29%29.GetProperty%28%22source_property_name_for_input%22%29%29]

    And since the created_by_id property never changes once item created you no longer need foreign "input" at all.

4 Replies

  • AFAIK, foreign properties are not filled until an actual write to the database occurs. So, your "input" is still empty in the OnBeforeAdd method. You need an additional query to get it value at this time.

    • RB2023's avatar
      RB2023
      Ideator I

      Thanks ALaxala, looks like you've hit the nail on the head. Have you got any guidance around what additional queries might be suitable? Thanks for your help!

      • alaxala's avatar
        alaxala
        Creator III

        Something like this

        [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:04d1adfb-19f5-4c80-b133-83b069ca2c8b:type=text&text=Dim%20Inn%20As%20Innovator%20%3D%20Me.getInnovator%28%29%0AMe.SetProperty%28%22output%22%2C%20Inn.GetItemById%28%22User%22%2C%20Inn.GetUserID%28%29%29.GetProperty%28%22source_property_name_for_input%22%29%29]

        And since the created_by_id property never changes once item created you no longer need foreign "input" at all.