Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
5 replies
Subscribers
5 subscribers
Views
2438 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Process
How do I optionally save a custom data output to an array? A script task custom
greggl
over 9 years ago
How do I optionally save a custom data output to an array? A script task custom Data Output requires a target output, so if I try and use an if conditional like this: if(pv!newStaff.hireDate > today(),pv!newStaff.firstName,{}), I end up with a array index of blanks, when I really want no array index added. I want to be able to only add to array index if condition is met but as target output is required, it's saving a blank rather than do nothing as desired.
How can this be done?
Thanks
OriginalPostID-147849
OriginalPostID-147849
Discussion posts and replies are publicly visible
0
Josh
Certified Lead Developer
over 9 years ago
you could either:
a) have a gateway that controls the process model flow and configure it so if pv!newStaff.hireDate>today() go to "scriptTaskToWriteToArray" else goto "nextScriptTask/skipWriteToArray".
b) you can filter out the blanks of the pv in another script task using the reject function and re save into the array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
If you're trying to handle the whole pv!newStaff array at once, you can probably make use of the index and where functions, such as:
index(
pv!newStaff,
where(pv!newStaff.hireDate > today())
).firstName
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Chris
over 9 years ago
Instead of using 'appended to' in the output condition, use append() in the expression and choose 'save as' for the condition. ex:
if(pv!newStaff.hireDate > today(),append(pv!YourArrayHere,pv!newStaff.firstName),pv!YourArrayHere) -> Save As -> pv!YourArrayHere.
Which will essentially either append a value to pv!YourArrayHere, or save the array back to itself (i.e. doing nothing).
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Amitkumar
over 9 years ago
You can also create an expression rule with following input parameters and definition.
Inputs : index(int), hireDates_DateArr (Date),firstNames_txtArr(Text)
Rule definition :
if(
ri!hireDates_DateArr[ri!index] > todate(
local(
now()
)
),
ri!firstNames_txtArr[ri!index],
null
)
Do apply on this rule when you have multiple hire dates and first names to filter.
=apply(rule!aboveRule,{enumerate(length(ri!hireDates_DateArr)+1)},ri!hireDates_DateArr,ri!firstNames_txtArr)
Note : todate(local(now())) gives exact today's date considering GMT time before 10 AM and after 5 PM.
Please add appropriate null checks for hireDates, and firstNames.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
nileshr
over 9 years ago
You can make a rule for removing a value from a particular index of an array(let's say rule!RemoveValue) with the following definition:
remove(ri!YourOutputVariable,ri!ValueToRemove)
After that, you can call the above rule in another rule like this:
apply(rule!RemoveValue,{wherecontains(null,ri!YourOutputVariable)},ri!YourOutputVariable)
Now, you can use this rule to filter null values from your array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel