Starwars Valued Contributor.
Valued Contributor.
313 views

Sort by Date

Jump to solution

Hello,

 

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?

 

Regards

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Knowledge Partner
Knowledge Partner

Re: Sort by Date

Jump to solution

I think we need some more details.

What tool is being used for the email? Is this all in User App, so external thing?

 

View solution in original post

0 Likes
6 Replies
Knowledge Partner
Knowledge Partner

Re: Sort by Date

Jump to solution

I think we need some more details.

What tool is being used for the email? Is this all in User App, so external thing?

 

View solution in original post

0 Likes
Starwars Valued Contributor.
Valued Contributor.

Re: Sort by Date

Jump to solution

Hello,

 

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?

 

 

0 Likes
Knowledge Partner
Knowledge Partner

Re: Sort by Date

Jump to solution

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.

 

0 Likes
Satz Respected Contributor.
Respected Contributor.

Re: Sort by Date

Jump to solution
you can convert your date to seconds and manipulate accordingly in your policy.

0 Likes
lkr Contributor.
Contributor.

Re: Sort by Date

Jump to solution

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 

0 Likes
Knowledge Partner
Knowledge Partner

Re: Sort by Date

Jump to solution

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.

 

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.