Programmatically add and remove person from itshop customers

Hi all experts,

I need to programmatically add and remove Person from ITShop customers.

I know there are a bunch of tables tracking that assignment, but I don’t know which is the one I need to target or if there is some method I can call on person or on ITShopOrg.

Please, some advices.

Thanks in advace

A

  • And of course, always PersonInITShopOrg.XOrigin = 1 :-)

  • Just an update:

    I have tryed this:

    Dim new_pis As PersonInITShopOrg = Session.Source.CreateNew(Of PersonInITShopOrg)
    new_pis.UID_ITShopOrg = uid_ItShopOrg
    new_pis.UID_Person = uid_person
    new_pis.AssignDirect()
    new_pis.Save(Me.Session)

    where uid_ItShopOrg is the customer node of an itshop and uid_person the uid_person of the employee I need to add.

    The script runs smoothly, but even if no error is raised, the employee is not put into the ItShop.

    So I've tryed on the following:

    Dim pis As ISingleDbObject = Me.Connection.CreateSingle("PersonInITShopOrg")
    pis.PutValue("UID_Person",uid_person)
    pis.PutValue("UID_ITShopOrg", uid_ItShopOrg)
    pis.PutValue("XOrigin",1)
    pis.Save()

    and it works pretty well in some environment but it does not work at all in some others...
    Obviously it is complaining that I can't edit XOrigin. The executing user in the second environment probably lacks some rights, but I'm not sure

    So the question is: how can i surely add a Person into the customer node if a ITShop?