Page 1 of 1

Get SecurityIdentity from Name

Posted: Tue Feb 01, 2022 4:09 pm
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!

Re: Get SecurityIdentity from Name

Posted: Mon Feb 07, 2022 2:29 pm
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 858 times

Re: Get SecurityIdentity from Name

Posted: Mon Feb 07, 2022 3:39 pm
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).

Re: Get SecurityIdentity from Name

Posted: Tue Feb 08, 2022 4:18 pm
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.

Re: Get SecurityIdentity from Name

Posted: Wed Feb 09, 2022 2:27 pm
by BobRichards
I'm glad you got it working. :)