Get SecurityIdentity from Name

Questions about and code samples for automation process code snippets within Select.
Post Reply
elimalone19
Posts: 23
Joined: Mon Jan 31, 2022 2:26 pm

Get SecurityIdentity from Name

Post by elimalone19 »

I need to create a task and assign it to an employee. How can I do that if I only have the employee's name?

Code: Select all

def add_task():
	task = IOrder.CreateNew(Context, 'RequestedTask')
	task.AssignedTo = ????
	Context.Tasks.Add(task)
I've seen similar things done on this forum with C#, but does anyone have an example with Python? Thanks in advance!
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Get SecurityIdentity from Name

Post by BobRichards »

Do you need logic beyond what is available in Select today in the Automation "Add a specific task"?
2022-02-07_13-27-42.jpg
2022-02-07_13-27-42.jpg (86.64 KiB) Viewed 813 times
Bob Richards, Senior Software Developer, SoftPro
elimalone19
Posts: 23
Joined: Mon Jan 31, 2022 2:26 pm

Re: Get SecurityIdentity from Name

Post by elimalone19 »

Yes, I was hoping to dynamically grab the Employee's name from a custom field (It won't always be the same person).
elimalone19
Posts: 23
Joined: Mon Jan 31, 2022 2:26 pm

Re: Get SecurityIdentity from Name

Post by elimalone19 »

I found a workaround. If someone has a better solution I'd be interested to hear it, but this is what I came up with for now:

Code: Select all

FormulaLanguage = Guid("1AB0C637-DB71-4461-B0E2-13BA9DDEFF0C")
my_string = IOrderItem.GetProperty(Context, 'MyCustomField#')

task = IOrder.CreateNew(Context, 'RequestedTask')
task.Code = 'UNIQUECODE'
Context.Tasks.Add(task)

for num in range(0, len(Context.Tasks)):
	if Context.Tasks[num].Code == 'UNIQUECODE':
		IOrderItem.SetFormula(Context.Tasks[num], 'AssignedTo', FormulaLanguage, "Value = '" + my_string + "'")
This serves my purpose well enough.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Get SecurityIdentity from Name

Post by BobRichards »

I'm glad you got it working. :)
Bob Richards, Senior Software Developer, SoftPro
Post Reply