11-28-2018 06:03 AM
An Autofill file updates Email Address Keyword (setup as MIKG) and contains up to 10 email address keywords. The Email Address then needs to be updated with another keyword value to create the "REAL" email address needed for notifications.
ACTION - AutoFill Keyword Set returns the following keyword values
Both Actions below return the results needed to update all the email addresses
Set Property Value - Keyword = Email Address - with Set property to all value instances checked
OR
Set Property Value from Keyword Record All Records = Keyword type = Email address - with Set property to all value instances checked
Updating the values of each keyword works as well:
Set Property to Expression Replace(CombineArray(%VpropEmail;"|");"([--])";%K00728;true) (Value of K00728 = TEST) Returns the value in this format
SendtoQATEST@email.com|SendtoRDTEST@email.com|SendtoMETEST@email.com
Action - Delete all Delete All Keywords of Certain Type - Email Address KW is then used to remove current emails
HOW do I update the keywords with all the new values? The number of email addresses varies for each document. I have tried several scenarios with arrays, splitting etc.
Has anyone else had to do something similar and if so can you help me out?
11-28-2018 05:15 PM
Ellen
Instead of reformatting all email addresses at once, then deleting the keywords, and trying to add the reformatted ones, you could process each email address individually by using recursion. Care should be taken when configuring recursive calls because you can end-up recursing infinitely which will require an app server reset or restart of whichever component is running the workflow logic (e.g. the Unity Scheduler).
Create an array property containing the email addresses and then use recursion to iterate through the array, updating each email address, then removing the email address that was processed from the array. The recursion stops when the array is empty.
The workflow layout should look like this (I created a System Task for ease of testing):
The rules and actions should be configured as follows:
ACTION: Create array of email addresses
Set Property Value from Keyword Record
Property: propEmailArray
Keyword Record: <whatever the name of the MIKG is>
Keyword Type: Email Address
Tick Set property to all keyword value instances
ACTION: Convert the array to a string:
Set Property to Expression:
Property Name: propEmailArray
CombineArray(%VpropEmailArray; ",")
TASK LIST: Update Email Address //everything below here, including a copy of the Update Email Address task list, is added to this task list
ACTION: Get size of string
Set Property to Expression
Property: propEmailArrayLength
Expression: Len(%VpropEmailArray)
RULE: Break processing if size of string is 0
Check Property Value
Property: propEmailArrayLength
Operator: =
Compare To: Constant value: 0
On True: ACTION: Break Processing: Break All Processing for Top-Level Item
On False: <leave empty>
ACTION: Get email address from string
Set Property to Expression
Property: propEmailAddress
Expression: Match(%VpropEmailArray;"([^,]*){1}$";true)
ACTION: Reformat email address
Set Property to Expression:
Property: propReformattedEmailAddress
Expression: Replace(%VpropEmailAddress; "--"; %K00728; true)
//The above two actions could be combined, but I've kept them separate for readability of the regular expressions.
ACTION: Replace email addr KW w/reformatted email addr
Replace Keyword
Keyword Type: Email Address
Old Keyword:
Property Name: propEmailAddress
New Keyword:
Property Name: propReformattedEmailAddress
//The next step is the most important - removing the processed email address element from the string!
ACTION: Remove email address from string
Set Property to Expression:
Property: propEmailArray
Expression: Match(%VpropEmailArray;".*\w(?=,)";true)
TASK LIST: Update Email Address
11-28-2018 05:15 PM
Ellen
Instead of reformatting all email addresses at once, then deleting the keywords, and trying to add the reformatted ones, you could process each email address individually by using recursion. Care should be taken when configuring recursive calls because you can end-up recursing infinitely which will require an app server reset or restart of whichever component is running the workflow logic (e.g. the Unity Scheduler).
Create an array property containing the email addresses and then use recursion to iterate through the array, updating each email address, then removing the email address that was processed from the array. The recursion stops when the array is empty.
The workflow layout should look like this (I created a System Task for ease of testing):
The rules and actions should be configured as follows:
ACTION: Create array of email addresses
Set Property Value from Keyword Record
Property: propEmailArray
Keyword Record: <whatever the name of the MIKG is>
Keyword Type: Email Address
Tick Set property to all keyword value instances
ACTION: Convert the array to a string:
Set Property to Expression:
Property Name: propEmailArray
CombineArray(%VpropEmailArray; ",")
TASK LIST: Update Email Address //everything below here, including a copy of the Update Email Address task list, is added to this task list
ACTION: Get size of string
Set Property to Expression
Property: propEmailArrayLength
Expression: Len(%VpropEmailArray)
RULE: Break processing if size of string is 0
Check Property Value
Property: propEmailArrayLength
Operator: =
Compare To: Constant value: 0
On True: ACTION: Break Processing: Break All Processing for Top-Level Item
On False: <leave empty>
ACTION: Get email address from string
Set Property to Expression
Property: propEmailAddress
Expression: Match(%VpropEmailArray;"([^,]*){1}$";true)
ACTION: Reformat email address
Set Property to Expression:
Property: propReformattedEmailAddress
Expression: Replace(%VpropEmailAddress; "--"; %K00728; true)
//The above two actions could be combined, but I've kept them separate for readability of the regular expressions.
ACTION: Replace email addr KW w/reformatted email addr
Replace Keyword
Keyword Type: Email Address
Old Keyword:
Property Name: propEmailAddress
New Keyword:
Property Name: propReformattedEmailAddress
//The next step is the most important - removing the processed email address element from the string!
ACTION: Remove email address from string
Set Property to Expression:
Property: propEmailArray
Expression: Match(%VpropEmailArray;".*\w(?=,)";true)
TASK LIST: Update Email Address
11-29-2018 01:07 PM
Thanks Mark! I have a lot of this code already but need to make a few of the changes you suggested. OB 16 is what I am working in.
I am going to print this and make notes. Am I able to use recursion? I understand the concept and have been coding a long time.
12-02-2018 01:34 PM
You're welcome, Ellen.
It looked like you had something close to what you wanted in your original post. I'm pretty sure I used this pattern in a v16 solution, so you should be right. I remember that it was complex enough at the time for me to document what I did and save it to my Code Snippets folder for future reference!
11-29-2018 01:55 PM
Can't thank you enough for sharing this... and making the expressions easy to copy and paste!!!
I have worked on this for the past week and getting nowhere FAST!
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.