Delete PersonInOrg Object (all Direct assignments) via Script ?

HI,

I am using Version 8.1 and trying to delete the assignments from PersonInOrg table via a Script.

I have written below script to test the method calls.

Already tried

  • Running from designer (test script option).
  • Also, tried putting script in a process and calling the Process chain from a custom event.

Both results ion same error saying as  - "[810222] Error executing script 'test_Deletion_PersonInORg'.
[System.NotSupportedException] Specified method is not supported."

PLease help with the sample script and right method to call for deleting entries in PersonInOrg table.

Script and method I used are as below :



End Sub

Public Sub test_Deletion_PersonInORg(ByVal strUID As String) 

Connection.BeginTransaction()

Dim strWherePersonInOrg As String= " UID_Org= '8faf76dd-a704-4dfc-862d-5cabae489329' and uid_person='5b8d9c93-aae1-4d9e-b2a2-c79819d1dfe9' "
Dim qPersonInOrgUIDs As Query = Query.From("PersonInOrg").Where(strWherePersonInOrg).Select("UID_Person","XObjectKey","UID_Org","XOrigin")							
Dim cPersonInOrgUIDs As IEntityCollection = Session.Source.GetCollection(qPersonInOrgUIDs)
		 For Each ePersonInOrgUID As IEntity In cPersonInOrgUIDs						
			Dim strUidPerson As String = ePersonInOrgUID.GetValue("UID_Person")
			Dim strXObjKey As String = ePersonInOrgUID.GetValue("XObjectKey")
			Dim strXOrigin As String = ePersonInOrgUID.GetValue("XOrigin").String

			ePersonInOrgUID.MarkForDeletion()
			ePersonInOrgUID.Save(Session)		
			
	     Next
Connection.CommitTransaction()	
	
End Sub

Parents
  • The default collection load-type is read-only. That's why your code is throwing method does not exist.

    So you need to specify a different collection load-type in the GetCollection method. I suggest using bulk.

    Explanation

    A collection load type can be provided as optional parameter to the GetCollection function.

    This parameter defines the contents and behavior of the loaded entities.

    Valid entity collection load types are:

    Default
    ------------------------------
    Loads read-only entities according to the supplied query. Loaded columns include the primary key,
    display columns according to the display pattern, some special columns, and the columns defined
    in the Select clause of the query. The entries will be sorted by the defined display or the optional
    OrderBy clause of the query. This load type is the default and can be omitted.

    Slim
    ------------------------------
    Works mostly like Default but does not load display columns and does not build an ORDER BY clause per default.
    This type is useful when loading data not intended for display and can save much time by using database indices.

    Bulk
    ------------------------------
    Loads entities that can be edited and saved. The loaded entities use the delayed logic mode.
    All columns will be loaded. The columns defined in the query will be overridden.

    BulkReadOnly
    ------------------------------
    Loads read-only entities with all columns filled. The columns defined in the query will be overridden.

    ForeignDisplays
    ------------------------------
    Loads display values for foreign keys contained in the display pattern too.
    This allows showing displays instead of UIDs for foreign keys.

    ForeignDisplaysForAllColumns
    ------------------------------
    Like ForeignDisplays, but loads displays for all foreign keys contained in the Select clauses of the query,
    not only columns referenced in the display pattern.

    LoadForeignDisplaysEvenWhenExpensive
    ------------------------------
    This option even loads displays for dynamic foreign keys, even when that means one additional query
    against the database for every row of the result. ATTENTION: This can be very expensive.

    Load types can be combined, but some combinations do not make sense. In that case
    the broader definition will be effective.

    For example the combination Bulk and BulkReadOnly will work like Bulk alone.

  • Thanks , I got it working using   Bulk  option while loading the collection,, Thanks

Reply Children
No Data