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

OnDiscarded table script

I'm trying to update affiliations when a person is added/removed from PersonInOrg.  The update is working correctly using a process with an Insert event.  However, the delete event does not work - I believe it is firing the delete event, but it seems to update affiliations using the data before the deletion occurs.  So now I'm trying to use an OnDiscarded table script in the PersonInOrg table, but it doesn't seem to be working either.  I'm wondering if the user info is already gone by the time the OnDiscarded script runs?   

Below is the script I'm using.  Any suggestions?


Dim affiliation As String = ""
Dim scopedAffiliation As String = ""
Dim f As ISqlFormatter = Session.SqlFormatter
Dim eLDAPAccountEnt As IEntity

affiliation = VI_Build_Affiliations( $UID_Person$, "CCC_scopedAffiliation", "0")
scopedAffiliation = VI_Build_Affiliations( $UID_Person$, "CCC_scopedAffiliation", "1")

If Not String.IsNullOrEmpty($UID_Person$) Then
Dim qPerson = Query.From ("LDAPAccount") _
.Where(f.AndRelation(f.UidComparison("UID_Person", $UID_Person$), _
"UID_TSBAccountDef In (SELECT UID_TSBAccountDef FROM LDAPAccount INNER JOIN TSBAccountDef ON LDAPAccount.UID_TSBAccountDef = TSBAccountDef.UID_TSBAccountDef WHERE TSBAccountDef.Ident_TSBAccountDef = N'Enterprise Directory Account')")) _
.Select ("UID_LDAPAccount", "CCC_affiliation", "CCC_scopedAffiliation")

eLDAPAccountEnt = Session.Source.GetCollection(qPerson).FirstOrDefault

If Not eLDAPAccountEnt Is Nothing Then
If Not affiliation = eLDAPAccountEnt.GetValue("CCC_affiliation").String Then eLDAPAccountEnt.PutValue("CCC_affiliation", affiliation)
If Not scopedAffiliation = eLDAPAccountEnt.GetValue("CCC_scopedAffiliation").String Then eLDAPAccountEnt.PutValue("CCC_scopedAffiliation", scopedAffiliation)
eLDAPAccountEnt.Save(Session)
End If
End If

Parents
  • You should use the System Debugger to debug the error. It allows you to do single step-debugging of your script in Visual Studio.

    When you open the System Debugger, and created the script library you can open the file Tables.vb and set a breakpoint to your script PersonInOrg_OnSaved.

    See my screenshot where I did it with the table script Person_OnSaved.

    Then start the System Debugger, switch to the Tables tab, select your PersonInOrg table, choose one entry of your PersonInOrg table using the ComboBox modify the object as needed an press the save button. Visual Studio will then stop at your breakpoint and you can use single step debugging or any other toolset of Visual Studio to solve your error.

    Please note that you might want to use the checkbox Transaction with rollback to avoid that any data is written to the One Identity Manager database.

    Again a screenshot using the Person table.

    HtH

Reply
  • You should use the System Debugger to debug the error. It allows you to do single step-debugging of your script in Visual Studio.

    When you open the System Debugger, and created the script library you can open the file Tables.vb and set a breakpoint to your script PersonInOrg_OnSaved.

    See my screenshot where I did it with the table script Person_OnSaved.

    Then start the System Debugger, switch to the Tables tab, select your PersonInOrg table, choose one entry of your PersonInOrg table using the ComboBox modify the object as needed an press the save button. Visual Studio will then stop at your breakpoint and you can use single step debugging or any other toolset of Visual Studio to solve your error.

    Please note that you might want to use the checkbox Transaction with rollback to avoid that any data is written to the One Identity Manager database.

    Again a screenshot using the Person table.

    HtH

Children
No Data