Page 1 of 1

trying to start workflow final

Posted: Tue Aug 02, 2016 2:54 pm
by jbrown
I've been tasked with reading through a local list of orders, trying to find them in SoftPro, and creating final workflow task if they are found. To kind of summarize where I've gotten to, I:

• Create a SelectServer object and test the authentication
• Use that object to get an IOrderStore
• Loop through my local list of orders
o For each order I look for a matching IOrderInfo matching our order number
o If I find it I open the IOrder
o Here’s where I’m at for the moment.

In trying to gather information about starting a workflow final for that order I did a search here on the forum and find answers like "there is currently no way to submit an order to workflow or assign a step to a user" and "there is no public API for workflow assignment, etc", with an indication that these sorts of things are coming. Is this functionality available now? Or is this still something that's coming soon?

Re: trying to start workflow final

Posted: Tue Aug 02, 2016 4:28 pm
by Melissa McBerkowitz
That information is still correct - we do not yet have public APIs for workflow processes or for submitting an order from one workflow step to another. We do, however, have full API support for the checklist and requested tasks within the order itself, so if the final workflow task you're creating is one of those, you have everything you need within that IOrder object. If you need more info about that option, please let us know!

Re: trying to start workflow final

Posted: Wed Aug 17, 2016 3:37 pm
by jbrown
Sorry, I may not have completed my due diligence in this investigation yet, but after a search in the SDK Documentation I don't find how to create a task and add it to the order. Stepping through my code I can see the tasks in the IOrder. Can you point me to the documentation around manipulating the task list itself?

Code: Select all

private void HandleFoundOrder(IOrder foundOrder)
{
            // Cast to dynamic to make order handling easier.
            dynamic order = foundOrder;
            IEnumerable<dynamic> tasks = order.Tasks;

            // Add a task here please
}

Re: trying to start workflow final

Posted: Wed Aug 17, 2016 5:19 pm
by BobRichards
This provides the template for creating Checklist and Requested tasks. Here I create a Requested Task and set up the bare minimum number of properties required - the description.

Code: Select all

public static void CreateTask(SelectServer ss, IOrder iOrder)
{
	// Get an instance of the desired task type and set properties.
	//  (Substitute "ChecklistTask" if you want to add one of those instead.)
	IOrderItem task = iOrder.CreateNew("RequestedTask");
	task.SetProperty("Description", DateTime.Now.ToString());

	// Get list of tasks and add all task types to it.
	IList tasks = (IList)iOrder.GetProperty("Tasks");
	tasks.Add(task);

	// As always, save the order if you changed it.
	IOrderStore os = ss.GetService<IOrderStore>();
	os.ApplyChanges(iOrder);
}

Re: trying to start workflow final

Posted: Mon Aug 22, 2016 8:44 am
by jbrown
I am getting the following error when I try to execute the CreateNew step:

Could not load file or assembly 'Microsoft.Scripting, Version=1.1.0.20, Culture=neutral, PublicKeyToken=7f709c5b713576e1' or one of its dependencies. The system cannot find the file specified.

It doesn't seem to be as simple as adding a using statement, and I don't find any obvious reference to add. I'm using .NET 4.6, can you tell me what reference I need to add to the project?

Re: trying to start workflow final

Posted: Mon Aug 22, 2016 12:35 pm
by BobRichards
Add "Microsoft.Scripting.dll" from the SoftPro client or server libraries to your project executable folder with the other Select DLLs. You do not need to add it to your project references, but it is needed for Select DLLs.

Re: trying to start workflow final

Posted: Tue Aug 23, 2016 11:40 am
by jbrown
Working up to a point, but when I get to the tasks.Add(task) I get a MemberAccessException. Is this a problem with accessing the order itself? I'm using an order that appears in my order list in SoftPro Select.

Re: trying to start workflow final

Posted: Tue Aug 23, 2016 12:20 pm
by BobRichards
Is your order read-only? The order must be opened as writable. Can you make any changes to the order and save it (such as Order.RelatedOrders)? I would need to see your code to make any other comments.

Re: trying to start workflow final

Posted: Tue Aug 23, 2016 2:34 pm
by jbrown
thanks. was opening as read-only