I created the following snippet to qualify when the HOA/HMC Contacts exceed the number of Requested Tasks. (I am sure there is probably a better way, but it works.)
from System import *
from SoftPro.ClientModel import *
from SoftPro.Select.Client import *
from SoftPro.OrderTracking.Client.Orders import *
for task in Context.RequestedTasks:
Codes = ['HOA']
if task.Code.upper() in Codes:
for cont in Context.Contacts:
Types = ['HOA', 'HMC']
if cont.Code[:3] in Types:
if contactCount > taskCount:
The problem I am having is that this only triggers once, regardless of the difference between Contacts and Tasks.
In this case, I assume that I will also need to use a Code Snippet to Add the Task x times based on the difference. I believe that I saw an example that uses a snippet to add a task, however, I believe it hardcodes each of the fields instead of assigning the values based on information pulled from the Lookup Tables.
Is there a way and/or any examples that might show me how to add a task based on the values defined in the Requested Task Lookup Table? (i.e. Similar to what Automation does when you add a task with only the Task Code and Task Name provided).
Thank you for any assistance you may provide.
By the way, I imagine that it is an artifact of your earlier testing, but you don't need the slice notation in "cont.Code[:3]" since you are comparing against the entire string - just "cont.Code".
I have used both "First Time" as well as "Every Time". It is currently set to "Every Time" because when it was set to "First Time" it only seemed to fire once regardless of adding Subsequent HOA/HMC Contacts during subsequent saves of the order.
I will try changing cont.Code[:3] back to just cont.Code, but I seem to recall having issues with cont.Code matching with 'HOA' or 'HMC' when the cont.Code contained HOA2, HMC3, etc... The "Code" assigned to each contact is incremented beyond the first entry, so I believe that HOA2, HOA3, HOA4 would not match Types without using the first three characters.
The code snippet appears to be firing when it sees a difference between the number of HOA/HMC Contact, with Names, and the number of "HOA" tasks that have been added.
The main problem I am now facing is how to dynamically add tasks to the order that are based on the values pulled from the Lookup Table, rather than being hardcoded in the snippet. (Similar to what Automation does when I only identify the lookupCode and Description.) I think I could use the current comparison logic to identify how many tasks need to be added, but I do not want to hard code each field of the task. I want to pull the current values from the Lookup table.
- "First Time" means the very first time the order is saved (that will only ever occur once in the lifetime of an order) and never again.
- "Every Time" means the first time the order is saved and for every save in the future.
Obviously, you are the expert so I do not mean any offense, but I have found the "First Time" actually works a bit different.
I too thought that "First Time" meant that the Process would only fire "on the first save attempt of the order" and thought this made no sense what so ever as SoftPro has a Profile setting that forces a save before a user even has a chance to touch the order when it is being created.
However, I have found this assumption was wrong and that "First Time" actually means that it will only fire the "First Time the Conditions are met" for the Process. (i.e. You can save the order 100 times without the condition being met, but on the 101st save if the conditions are met the Process "Does Fire" and will then never fire again for the same process.
As for my question about how to use the Lookup Table to dynamically load a task, I realize that you are not intended to be an ad-hoc programmer for less experienced people flagrant abusing the forum looking for handouts but this was not my intent. I was simply looking to see if this was even possible and if there happened to be any basic examples/concepts that I could digest and possibly build from.
Before I even posed the question, I did search the forums and believe I found examples of how to add Hardcoded Tasks similar to what Workflow does. However, I do not recall that I found any examples or confirmation that Automation and IronPython code could even access the content of a Lookup Tables to be used in the output. I would think that I could use Automation to assign orders to Workflow, but as I recall I was told this coudl not be done either. if I missed finding an example of this, then that is my bad and I will look again.
I am taking your response as confirmation that Automation Processes using IronPython Code can, in fact, access Lookup Table Values and use these values to dynamically create tasks.
I will look to see if there is a non-python example that I can make work as python code.
For example, if your lookup table is based on Code, and you know you want to always pull the "ABC" entry on your lookup table, you just have to set the code property on the task to "ABC". That will automatically do a lookup operation and populate remaining fields based on the lookup table.
Please let me know if this is not the case and you do need to inspect all the values in the lookup table.