Find ADSAccounInAdsgroup or PersonInOrg where XOrigin = '1' and auto CreateOrder in IT Shop for this assignments

Hello everyone, tell me, we have many assignments for users with Xorogin = 1, 
both in the PersonInOrg table and in the ADSAccountInADSGroup table.
Many of the ADSGroup and ORG have been hosted on the ITShop for a long time, but for many users they have remained assigned hands.
There is a desire to set up a process that, according to a specific Insert event for the PersonInOrg / ADSAaccountInADSGroup table,
will launch a script that will find such requests and automatically create a request for them in the IT Shop.

select UID_ADSGroup from ADSAccountInADSGroup where UID_ADSGroup in
(select g.UID_ADSGroup from ADSGroup g
left join AccProduct ap on ap.UID_AccProduct = g.UID_AccProduct
where g.IsForITShop = '1') and XOrigin = '1'

or

select UID_Org from PersonInOrg where UID_Org in (
select o.UID_Org from Org o
left join QERAssign q on q.ObjectKeyAssignTarget = o.XObjectKey
where q.IsForITShop = '1') and XOrigin = '1

Question: how can I create such requests automatically?





Public Sub CCC_ITShop_CreateOrder_whereXOrigin1 (ByVal UID_Person As String )

Dim groupWhereClause As String = ""

groupWhereClause = "UID_Org in " & _
" (Select o.UID_Org from Org o " & _
" left join QERAssign q On q.ObjectKeyAssignTarget = o.XObjectKey " & _
" where q.IsForITShop = '1') and XOrigin = '1' and UID_Person = '" + UID_Person +"'"

Dim PWOs = Session.Source().GetCollection( _
Query.From("PersonInOrg").Where(groupWhereClause).Select("UID_Org"))

For Each PWO As IEntity In PWOs
Dim dbPWO As ISingleDbObject

dbPWO = Connection.CreateSingle("PersonWantsOrg")
dbPWO.PutValue("UID_Org", PWO.GetValue("UID_Org"))
dbPWO.PutValue("UID_PersonInserted", UID_Person) 'UID Person того кто создал заявку
dbPWO.PutValue("UID_PersonOrdered", UID_Person) 'UID Person того для кого запрошен доступ
dbPWO.PutValue("OrderReason","NewRequest where XOrigin - 1")


dbPWO.Save
Next


End Sub


I tried this script, but it gives the following error:
[810222] Error executing script 'CCC_ITShop_CreateOrder_whereXOrigin1'.
    [810306] Error during execution of 'OnSaving' in logic module 'QER.Customizer.PersonWantsOrg'.
    [2133173] This employee Тестовов Тест Тестович (test.testovov) is not authorized to make requests at this point.
 
Any help on this matter, thank you!