Can someone please assist me here. I am trying to send an email notification with list of users who has future hiredate and I can fetch all details correctly as needed, however I would need to sort users based on hiredate either in ascending order or descending order. Any inputs?
I have written this in driver policy, The User are created in vault with an attribute called hiredate along with firstname, lastname , I'm running a job to send an email to our team with future hire records to do other things, In that I will fetch hirdate, employeeID, manager details, I get the email correct with all needed details however I want to get the users based on hiredate ascending order.
Does it help?
Yes, makes a huge difference. I.e How I would do it in policy vs Workflow is totally different.
Ok, so you have a query that pulls out your users in an XML document (<instance> node) which is unsorted.
I have a couple of ideas.
One: It was pointed out that when you use a index (maybe only compound, but i think all indexes), the values returned are actually sorted according to the indexed attribute. Could you make an index on the engine server for this attribute and make sure to query such that the index is used? Then you would get automatically sorted data back. Time Syntax attrs are really 32 bit integers under the covers, so that might just do the trick.
Second: You would have to do it in ECMA. And there I leave the task.If you just wanted the list of dates out the doc, I could select them all in XPATH into a nodeset pass that into ECMA and sort it. Trickier since you need the entire document sorted. I defer to betters at ECMA than me to accomplish this task.
I am also even in the same situation. Though I can convert into seconds not sure which noun/verb exactly I need to use to sort the specific local variable/attribute. If there is any example policy xml if you can post here that will be really helpful
Internally, eDir stores Time attributes as CTIME, which is an integer as a count of seconds since 1970.
So if you have a date/time field in eDir you want to sort, simply read them, they come back as an integer.
If you need to convert it, use:
Reformat Op Attr (your Attr name)
Convert Time, $current-value and specify the source format and CTIME as the Dest format.
current-value is a magic variable only for use in Reformat Op Attr, (current-node is for for-each). So you define a reformat for a single variable current-value and it does to each value in the docment for that attribute.