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
22 replies
Subscribers
8 subscribers
Views
7183 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
Hi, I want to use Apply function over generateuuid, so I am taking an
rishub356
over 9 years ago
Hi,
I want to use Apply function over generateuuid, so I am taking an expression like given below:
=apply(fn!generateuuid, {ri!test})
here ri!test is a text array. But when I am running this rule, I am getting the below error:
Expression evaluation error at function 'apply': com.appiancorp.suiteapi.common.exceptions.AppianException: Unexpected number of parameters. (APNX-1-4158-001)
Can anyone guide us how can I do it. I don't want to use MNI.
Thanks
Rishu
OriginalPostID-194546
OriginalPostID-194546
Discussion posts and replies are publicly visible
0
PhilB
A Score Level 1
over 9 years ago
Does fn!generateuuid() take any parameters? If not, you might want to use fn!repeat() rather than fn!apply().
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
Additionally, if ri!test is an array, it's unnecessary to wrap it in curly braces as that will result in an array with a single entry that is also an array.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rishub356
over 9 years ago
hey Phil, repeat function is generating duplicate values. Not unique value every time.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
@rishub I confirm from my testing results that fn!generateuuid() is generating duplicate values when repeat() and apply() (I have wrapped the fn!generateuuid() in an expression rule and has applied apply() over it.) are used over it.
At the same time what I have noticed is, fn!generateuuid() is generating distinct values when the node in the process is MNIed. So if possible, try looking at possibility of implementing MNI to get the distinct values when fn!generateuuid() needs to be invoked multiple times. To the best of my knowledge and as per my observation, the function is expecting a fresh or new context every time to generate a distinct value.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rishub356
over 9 years ago
hey Sikhivahans, The issue is that I don't want to use MNI. We may have the number values upto 500. MNI can be a costly expression for us in terms of time, it would take.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
I think you may be stuck with using an MNI for that particular function. At a guess, I'd say that the behaviour you're seeing is caused by the expression evaluating simultaneously rather than sequentially - so you get all the same uuids.
What exactly are you using the uuids for? Can you use something other than a uuid in this instance?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Angad Walia
Appian Employee
over 9 years ago
There are a few different ways to create GUIDs not using the plugin function. Ideally you should make some reference to the time at the millisecond in order to ensure uniqueness. Here are some examples of functions:
Examples:
datetext(now(),"yyyyMMddHHmmssSS")&ri!objectID
datetext(now(),"yyyyMMddHHmmssSS")&text(rand()*999,"000")
dec2hex(datetext(now(),"yyyy"))&
dec2hex(datetext(now(),"MMdd"))&
dec2hex(datetext(now(),"HHmm"))&
dec2hex(datetext(now(),"ssSS"))&
dec2hex(text(rand()*999,"000"))
Utilizing these would allow you to use a function like apply rather than resorting to intensive MNI
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
narasimhaadityac
A Score Level 2
over 9 years ago
@Rishub, try this alternative if it works for you. use a query database and use the below query:
SELECT SYS_GUID() A FROM DUAL D CONNECT BY LEVEL < 500
if you want you can parameter 500 as a parameter, this guarantees unique values without MNI in this case.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
@Angad Whilst it's true that UUID functionality will often make use of time in some aspect of identifier generation, "some reference to the time at the millisecond" absolutely does not guarantee uniqueness. Introducing functions such as rand() will decrease the changes of two identifiers being the same, but till does not guarantee uniqueness - and such advice is, quite frankly, extremely misleading.
Using a database select of UUID() as suggested above might be a better way - though it may still require a looped call as in the MNI suggestion above.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Chris
over 9 years ago
To expand on the DB approach, you can also make use of the execute stored procedure plugin function to generate UUIDs directly in SAIL forms or script tasks, node outputs, etc. Example code attached (MSSQL). For performance, this method only takes 20 milliseconds to generate 500 UUIDs in our environment.
INF_generateUuid.SAIL
INF_generateUuid.SAIL
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>