Novell Home

Getting the Current Time into the UserApp Flow

Novell Cool Solutions: Tip
By Martyn Durrant

Digg This - Slashdot This

Posted: 11 Jul 2007


A Forum reader recently asked:

"I'm using UserApp 3.5. I'm trying populate an attribute during the flow with the current time in seconds. However, none of the getTime() or getDate() type methods in the ECMAscript defaults are working. I've tried doing this at different stages of the workflow.

For example, I tried applying getDate() as the Pre Activity and get the following error message:

Failed to retrieve data items for provisioning request form

And here's the response from Martyn Durrant...


The example I've included at the end of this tip probably won't give you exactly what you want, but I hope it's a pointer. I use this in a Map activity when I want to place the current time in a flowdata variable and then put the flowdata variable's value in the Entity's attribute Data Item Mapping.

One thing I would say is that UserApp 3.5.0 doesn't always seem that great on handling dates and times, especially when transferring them between the Provisoning Request in UserApp and eDirectory. As a result, I have developed a clumsy but sure way of transferring dates and times from Provisioning Requests to eDirectory.

1. I extend the schema of the target object class in eDirectory to include a Case Ignore String single valued attribute with almost exactly the same name as the Date/Time attribute I wish to update.

2. I take the output from the function shown at the foot of this posting and use an Entity Activity to place that string version of the date into the string attribute of the eDirectory object.

3. A Policy Rule in my IDM Null Service Driver takes the string attribute's value and converts it to a proper date/time value and transfer it to the real attribute.

As I say, this seems a bit clumsy but it's safe.

If you are trying to pass a date into a provisioning request from IDM, then I think the format you will need to pass for a date is something like
where ZONE is your offset from UTC/GMT in hours and minutes. So for 1 November 2006 in France, it would be 20061101120000000+0100; and I suppose for 15 June 2007 in Boise, ID it would be 20070615120000000-0600. I think if you're lucky, you can also use this format to put dates directly into eDirectory date attributes from Provisioning Requests; however, I persevere with the other method because I don't want to rewrite my tested code.


function setTroyTime() {
 setTroyTime_date = new Date();
 setTroyTime_year = setTroyTime_date.getUTCFullYear().toString();
 setTroyTime_month = setTroyTime_date.getUTCMonth() + 1;
 setTroyTime_month = setTroyTime_month.toString();
 setTroyTime_days = setTroyTime_date.getUTCDate().toString();
 setTroyTime_hours = setTroyTime_date.getUTCHours().toString();
 setTroyTime_minutes = setTroyTime_date.getUTCMinutes().toString();
 setTroyTime_seconds = setTroyTime_date.getUTCSeconds().toString();
 setTroyTime_milliseconds  = setTroyTime_date.getUTCMilliseconds().toString();
 if (setTroyTime_month.toString().length == 1){setTroyTime_month = '0'  + 
 if (setTroyTime_days.toString().length == 1){setTroyTime_days = '0'  + setTroyTime_days;}
 if (setTroyTime_hours.toString().length == 1){setTroyTime_hours = '0'  + 
 if (setTroyTime_minutes.toString().length == 1){setTroyTime_minutes = '0' 
 + setTroyTime_minutes;}
 if (setTroyTime_seconds.toString().length == 1){setTroyTime_seconds = '0' 
 + setTroyTime_seconds;}
 if (setTroyTime_milliseconds.toString().length == 1){setTroyTime_milliseconds 
= '00' + setTroyTime_milliseconds;}
 if (setTroyTime_milliseconds.toString().length == 2){setTroyTime_milliseconds 
= '0'  + setTroyTime_milliseconds;}
 setTroyTime_deciseconds = setTroyTime_milliseconds.toString().substr(0,1);
 setTroyTime_formattedTime = setTroyTime_year + setTroyTime_month + setTroyTime_days 
+ setTroyTime_hours + setTroyTime_minutes + setTroyTime_seconds + setTroyTime_deciseconds;
 return setTroyTime_formattedTime.toString();

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions.

© 2014 Novell