This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Updating PersonInOrg

Hi

Normally, we will want to update DB objects as such 

 

Dim dbObject As IEntity

dbObject = Session.Source.Get("CustomTable", UID_CustomTable)
dbObject.PutValue("column", "newvalue")

We wanted to update UID_Org in PersonInOrg as part of our processes. 

However, as PersonInOrg is a view, does not have primary keys and UID_Person and UID_Org are its foreignkeys, how do we uniquely call one single DB object, especially when it does not have a primary key?

We have tried calling the object via XObjectKey, but an error is thrown, saying that "Number of primary keys columns do not match".

Is there a safer/better way to update values to such views/tables? We have tried using SQL formatter to call, but we are stuck not knowing how to retrieve the actual db object and update the particular PersonInOrg object. 

Thank you.

  • PersonInOrg is an M:N table and UID_Person and UID_Org are both parts of the PK. 

    That means, that you cannot update those foreign keys instead you need to delete the old entry and create a new one.

    This has nothing to do with views or tables.

    Sample code to load an entry and delete it:

    ' Load PersonInOrg entry based on XObjectKey of PersonInOrg
    Dim dbObject As IEntity = Session.Source.Get(New DbObjectKey(XObjectKeyPersonInOrg))
    ' Delete the entry
    dbObject.MarkForDeletionWithoutDelay()