You are viewing limited content. For full access, please sign in.

Question

Question

Workflow condition variable

asked on February 4, 2023

Hi all, 

As a new Laserfiche users, I am  looking for the best method to approach a problem. 

 

I am invoking a workflow by means of a schedule to then kick off a form. Its a leave form that has different types of leave based on what is pulled from a database. My two questions are

1. In the email to the user I am trying to add some text to let the user know what type of leave it is.  I have tried doing this by placing a normal text field with the calculation to set its wording to the correct leave status e.g 1 = Sick leave. The calculation works in the form, however because I think the form is being invoked by the business process this does not show.

2. I can however set the text field value from the workflow, I've done this by way of using conditions, however it does seem inefficient,  as I have to create 15+ conditions of invoking a workflow and having it write a different variable status in each one. What was a way where I can use the condition to determine the leave status as mentioned before e.g 1 = sick leave 2 = annual leave. I can't seem to find a variable to use with conditions.

Any help appreciated!

0 0

Replies

replied on February 6, 2023 Show version history

Regarding #2: I'm thinking you probably want to use the "Token Calculator" activity with the CHOOSE formula.

This takes in a numerical index value (which can be an incoming token) and returns the value from a list, based on the value of the index.

Example: 

CHOOSE(%(Leave Type),"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten")

When %(Leave Type)=3 it returns "Three", when %(Leave Type)=7 it returns "Seven", etc.

 

Regarding #1: Unfortunately, for the field with the formula to populate, the form needs to recognize that the field it is calculating from has been modified.  If the field is populated by a user or a lookup, it triggers a change event, which causes the formula to update.  But if the field is already populated from a prior task (including from a workflow) it doesn't reflect the change event, so it doesn't trigger the field with the formula to update.  One workaround is the one you mentioned, populating the field by the Workflow (annoying duplicating the calculation, but it works).  Another workaround is using Javascript to trigger the change event.  But that does mean it may be triggered more often than you want, so you have to be careful how you set it up if that is an issue.  If you want to pursue that option, I'm happy to help provide some code snippets.

 

Edit to add:  the suggestion by @████████ is a good idea because that ensures you are working from the same list in both Forms and Workflow, and updating the list means updating the database table instead of having to update both Forms and Workflow.  The suggestions I made assumed you didn't have or didn't want to make use of a database for lookups, but if you do, that's better in the long-run.  However, be aware that there is still the issue on the form, where the lookup won't be triggered by the index value populated from Workflow, the same way that the calculation isn't being triggered by the index value.  So you still might want some Javascript to trigger than change event, or want to pre-populate that second field from the Workflow.

1 0
replied on February 6, 2023

1. In the email to the user I am trying to add some text to let the user know what type of leave it is.  I have tried doing this by placing a normal text field with the calculation to set its wording to the correct leave status e.g 1 = Sick leave. The calculation works in the form, however because I think the form is being invoked by the business process this does not show.

 

Does the Leave Status get pulled from the database as a numeric value?  If so, you could create a lookup database with the status types and their corresponding number, then do a lookup to extract the exact text.  That text could be passed to the business process form.

 

2.  I can however set the text field value from the workflow, I've done this by way of using conditions, however it does seem inefficient,  as I have to create 15+ conditions of invoking a workflow and having it write a different variable status in each one. What was a way where I can use the condition to determine the leave status as mentioned before e.g 1 = sick leave 2 = annual leave. I can't seem to find a variable to use with conditions.

Again, I think creating a lookup table might solve for all the conditions you need, which I agree is inefficient.

 

Hope this helps... let me know if I misunderstood anything.

1 0
replied on February 6, 2023

Hi Franz and Matthew, 

 

Thank you very much for the detailed responses. We're just in the process of losing our Laserfiche Guru so I'm it at the moment! 

Franz the database lookup is a great idea, these are new concepts to me so thanks for the suggestion I will try that.

 

Matthew thanks for that Token Calculator solution,  I can see using that in other scenarios.

 

Really need to get onto that update, (to use javascript with modern designer) I think that can unlock alot of potential.

 

Thank you very much again, it is very much appreciated!

 

 

 

 

1 0
replied on February 6, 2023

Happy to help.

There's definitely some good stuff with the update (11 Update 3).  Just be aware that the Javascript functionality on the Modern designer is going to be more limited than what you may be used to on the Classic designer.  On the Modern Designer, the scripts run within a sandboxed iFrame and thus can only access the form components via the LFForm object.  The list of options that it can access/modify are listed here: https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Default.htm#../Subsystems/Forms/Content/Javascript-and-CSS/JavaScript-in-the-Forms-Designer.htm

You still have all of the Javascript ability to do calculations, loops, functions, etc. - the limitation is just with how much of the form/window that can be manipulated.

That said, the Modern designer has some really cool stuff with Field Rules and CSS/Structure that give the Classic designer a run for its money.  It's just a matter of balancing between the two for different situations.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.