Orchestrated process to limit the amount of specified roles to one at a time from IT SHOP

I'm trying to make an Process to limit users from having more than one resource from the IT SHOP at a time, i have four roles, so if the user already have one and asks for another, the event will trigger (Insert in PersonInOrg) and will automatically remove the resources leaving just the new one requested

The first step is the trigger, the second one is an Handle Object Component - Delete, it has two parameters, ObjectType that i filled with Value = "PersonInOrg" and a WhereClause that i filled with a code in VB but i had no success making it work

Value = "UID_Person = '" & CStr(Value("UID_Person")) & "' AND UID_Org <> '" & CStr(Value("UID_Org")) & "' AND UID_Org NOT IN ('d5ca7641-5991-4d37-9e9c-3afe471f51d8', 'bfaceda4-7c9e-496a-a290-4931c4e2bcd5', 'd700f418-da20-41ee-9918-db4b33f9a3c7', 'a22806e8-1b17-4fde-a594-273c9b8cebfc')"

how should i do? use a script? keep the handle object and change the code?

Parents
  • Hi Fernando,

    A few things;

    Consider adding a step to your workflow to create an event. This should allow you to start a process when the workflow starts (as you say; 'during request') to cancel the old request.

    You can even consider adding the step at the end of your workflow (as the final step) so that the revocation happens right before the assignment of the new resource (But after the approval).

    Also, what you should do is call the method to cancel the previous order. That way the underlying item should be removed (with the XOrigin = 2). If you try and remove the record directly it'll fail or (if you update the XOrigin to 1 so it works, only doable with SQL) you'll create database inconsistencies :).

    A final consideration... If possible consider using something other than UID's to find the orgs, as UID's for data objects (such as org's) are often not the same between environments. A marker in a customProperty of the Org's or some other way to identify them will give you a lot more flexibility.

Reply
  • Hi Fernando,

    A few things;

    Consider adding a step to your workflow to create an event. This should allow you to start a process when the workflow starts (as you say; 'during request') to cancel the old request.

    You can even consider adding the step at the end of your workflow (as the final step) so that the revocation happens right before the assignment of the new resource (But after the approval).

    Also, what you should do is call the method to cancel the previous order. That way the underlying item should be removed (with the XOrigin = 2). If you try and remove the record directly it'll fail or (if you update the XOrigin to 1 so it works, only doable with SQL) you'll create database inconsistencies :).

    A final consideration... If possible consider using something other than UID's to find the orgs, as UID's for data objects (such as org's) are often not the same between environments. A marker in a customProperty of the Org's or some other way to identify them will give you a lot more flexibility.

Children