If Then control in item Action

Suggestions for new functionality in NiceLabel. Do you want some feature but can't find it in the NiceLabel software? Post your wish here. Note: This is not a support forum.

Moderators: Georges, milos, NiceLabel Support Team

Post Reply
NickM
Newcomer
Posts: 3
Joined: Mon Jul 01, 2019 8:00 pm

If Then control in item Action

Post by NickM » Mon Jul 01, 2019 8:12 pm

It would be a great benefit if I could easily add an If statement in an item's "Action". I know I can do this by adding a VBScript to the action, but this seems like it would be so much easier and faster if I could add it under the "All Actions" dropdown without having to write scrip every time in the same way that I can add a "For Loop" in the dropdown.

NickM
Newcomer
Posts: 3
Joined: Mon Jul 01, 2019 8:00 pm

Re: If Then control in item Action

Post by NickM » Mon Jul 01, 2019 9:05 pm

An example where this would come in handy.
- User clicks a print button on the form.
- A message box pops up asking if the correct paper has been inserted (Yes/No response on the message box that sets variable)
- Action, If variable = Yes Then continue to the steps to print

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 85
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: If Then control in item Action

Post by Mytch » Mon Jul 01, 2019 10:26 pm

Nick,

Thanks for the suggestion.

Please note that is is possible to use a Condition to determine if an Action is executed or not. In the Action's Execution and Error Handling area, there is an option to have the Action Enabled only under certain conditions. This Condition uses the same scripting language that is configured in your Form Properties. See below for an example:
screenshot_20.jpg
screenshot_20.jpg (77.55 KiB) Viewed 1220 times
In this case, when the variable "YesNo" is equal to "Yes", the Open Label (and sub-actions) will execute. If the value is anything else, then the Action will not execute. We understand this is not the exact request you have made, but the existing functionality should be usable in most scenarios.

Mytch

highfrost
Enthusiast
Posts: 13
Joined: Tue Aug 19, 2014 10:51 am

Re: If Then control in item Action

Post by highfrost » Mon Jul 15, 2019 5:08 pm

Just to add to what Mytch said,
the group option is perfect to make this readable and easy to maintain. Also you only need to put the conditions once.
See below an example how I use these as my if-statements.
Attachments
2019-07-15_17-03-03.jpg
2019-07-15_17-03-03.jpg (127.38 KiB) Viewed 1150 times

user12
Valued Contributor
Posts: 22
Joined: Fri Jun 14, 2019 8:28 am

Re: If Then control in item Action

Post by user12 » Tue Aug 27, 2019 11:37 am

Hello,
I have used Group action to perform if..else execution. i have two groups where with one condition actions under first one should perform and with an another condition the actions under the second Group must perform. but on execution, only the first group is executed. the second one is not responding eventhough the condition for the second group is given. I enabled the 'Ignore failure' option to continue the flow of execution. Can anyone help me?

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 85
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: If Then control in item Action

Post by Mytch » Tue Aug 27, 2019 12:07 pm

user12 wrote:
Tue Aug 27, 2019 11:37 am
Hello,
I have used Group action to perform if..else execution. i have two groups where with one condition actions under first one should perform and with an another condition the actions under the second Group must perform. but on execution, only the first group is executed. the second one is not responding eventhough the condition for the second group is given. I enabled the 'Ignore failure' option to continue the flow of execution. Can anyone help me?
Hi,

Please post a screenshot of your actions and each of your group's conditions. Each Enabled Condition is a small script that executes, so if the group fails to execute, it implies the syntax is not correct or not meeting the condition.

For example, if the language is VBScript and condition is to only execute when [Variable] > 1, then this can easily fail, because by default NiceLabel variables are string types. You may be prevented from using arithmetic operators on a non-number type. In this example, the solution is to cast the variable as a number type (like int).

We can determine the exact issue if you post the additional info.

user12
Valued Contributor
Posts: 22
Joined: Fri Jun 14, 2019 8:28 am

Re: If Then control in item Action

Post by user12 » Tue Aug 27, 2019 1:00 pm

Hello, Thankyou for the reply. the group conditions are in python script. conditions are variable T value = S for store and P for print. variable T gets its value from file triggers.
Attachments
Test.png
Test.png (20.53 KiB) Viewed 688 times

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 85
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: If Then control in item Action

Post by Mytch » Tue Aug 27, 2019 6:14 pm

user12 wrote:
Tue Aug 27, 2019 1:00 pm
Hello, Thankyou for the reply. the group conditions are in python script. conditions are variable T value = S for store and P for print. variable T gets its value from file triggers.
user12,

Thanks for the info. Based on your screenshot, your trigger is only capable of processing a single payload at a time. In this case, your condition can only be true for one group or the other per trigger execution. When Automation receives the data, T.Value will either equal "S" or "P" only so both Groups cannot execute.

If T.Value = "S" during execution, then Group 1 will be used to store. If the next payload has T.Value = "P" during execution, then Group 2 will be used to print. If your payload has multiple rows in a single file, then you need to use a loop to execute the actions for each row. This is most easily done with a Structured Text data filter. A data filter will be configured like shown below:
screenshot_05.jpg
screenshot_05.jpg (25.3 KiB) Viewed 679 times
In Automation Manager, we can see from the logs that first record is set to Store the label and the second record prints. This has worked for us:
screenshot_04.jpg
screenshot_04.jpg (124.34 KiB) Viewed 679 times
If you still have issues, we will need to collect your Automation Configuration (.MISX), label file (.NLBL), and payload (file Automation processes for data).

Thanks,
Mytch

user12
Valued Contributor
Posts: 22
Joined: Fri Jun 14, 2019 8:28 am

Re: If Then control in item Action

Post by user12 » Wed Aug 28, 2019 7:03 am

Thankyou Mytch for the detailed reply. I need only one of the groups to be executed as per the conditions,either Store or Print. From group onwards actions are not executed. Could you please check the configuration.
Attachments
Init.txt
(3 Bytes) Downloaded 13 times
TestFile1.txt
(4 Bytes) Downloaded 15 times
TestSolution.misx
(3.86 KiB) Downloaded 11 times
TestSolution.nsln
(2.63 KiB) Downloaded 11 times

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 85
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: If Then control in item Action

Post by Mytch » Thu Aug 29, 2019 10:11 pm

user12 wrote:
Wed Aug 28, 2019 7:03 am
Thankyou Mytch for the detailed reply. I need only one of the groups to be executed as per the conditions,either Store or Print. From group onwards actions are not executed. Could you please check the configuration.
user12,

Okay - I tested your files. One problem is you did not attach the label but some Test Solution instead. It's okay, because label design doesn't really matter, so I made some new one.

When I test your trigger as-is with TestFile1.txt having value of "P", there are no problems with executing and printing a label. See below:
screenshot_10.jpg
screenshot_10.jpg (161.13 KiB) Viewed 615 times
When I test your trigger as-is with TestFile1.txt having value of "S", there are no problems with executing and printing a label. See below:
screenshot_11.jpg
screenshot_11.jpg (156.79 KiB) Viewed 615 times
This is only when using Preview, though. You mention you need to turn on "Ignore failure" to keep actions flowing, so maybe something else is happening to stop trigger from continuing. If your issue is still not resolved, I recommend to open a support case here:
https://www.nicelabel.com/support

Regards,
Mytch

user12
Valued Contributor
Posts: 22
Joined: Fri Jun 14, 2019 8:28 am

Re: If Then control in item Action

Post by user12 » Mon Sep 02, 2019 9:42 am

Thankyou Mytch for the checking the files and for the support. Sorry for the late reply. The issue is resolved.

User avatar
Mytch
NiceLabel Support
NiceLabel Support
Posts: 85
Joined: Fri Jul 13, 2018 10:26 pm
Location: Milwaukee, Wisconsin
Contact:

Re: If Then control in item Action

Post by Mytch » Tue Sep 03, 2019 11:36 pm

user12 wrote:
Mon Sep 02, 2019 9:42 am
Thankyou Mytch for the checking the files and for the support. Sorry for the late reply. The issue is resolved.
No problem at all - glad to hear. :)

Post Reply