Apply Template From Automation
Posted: Thu Jul 20, 2023 11:11 am
SoftPro Developer Team,
Currently, I'm having some issues with applying a template from a python automation, but not from C#.
Working C# Code
Failing Python Code
The error I receive in Automation is "OrderStore object has no attribute Orders", when trying to set the info variable, which seems to contradict the documentation.
Please let me know if you have any direction here. The main objective is to add logic to an automation and apply different templates based on conditions without needing to create separate automations.
Thank you,
Tim
Currently, I'm having some issues with applying a template from a python automation, but not from C#.
Working C# Code
Code: Select all
// Apply Template
IOrderStore os = SelectServer.GetService<IOrderStore>();
IOrderInfo info = os.Orders.Where(t => t.Number == "Template").FirstOrDefault();
IOrder template = os.OpenOrder(info, OrderEditMode.ReadOnly);
o.ApplyTemplate(template);
Code: Select all
def AddTemplates():
os = Context.Root.GetService(IOrderStore)
info = os.Orders.Where(lambda s: s.Number == "Default").FirstOrDefault() // Error Here
template = os.OpenOrder(info, OrderEditMode.ReadOnly)
Context.ApplyTemplate(template)
AddTemplates()
Please let me know if you have any direction here. The main objective is to add logic to an automation and apply different templates based on conditions without needing to create separate automations.
Thank you,
Tim