Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Import acrobat form (update JavaScript calculation of time) to livecycle Designer ?

Avatar

Avatar
Boost 1
Level 1
NicolasB_
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
NicolasB_
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
NicolasB_
Level 1

23-01-2018

Hi,

I retrieve and edit an acrobat form with date calculations.

When I import it into livecycle, the JavaScript script does not work.

Would there be someone who could update the javascript in LCD?

https://adobe.ly/2n5oY3l

snip_20180123232212.png

Thanks You

>Nicolas B.

Ce message a été modifié par : nicolas barbaz

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct Reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct Reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

24-01-2018

In LiveCycle Designer you'll have to modify your calculations scripts.

For example the calculate script of the field TimeHHMM.0:

The AcroForm script …

event.value = '';

// get the start time

var sStart = this.getField('TimeIn.0').value;

// get the end time

var sEnd = this.getField('TimeOut.0').value;

// complete script if we have data

if(sStart != '' & sEnd != '') {

// convert sStart string to seconds

var fStart = Time2Num('hh:mm', sStart);

// convert sEnd string to seconds

var fEnd = Time2Num('hh:mm', sEnd);

// convert sEnd string to seconds

var fEnd = Time2Num('hh:mm', sEnd);

// compute difference in seconds

var fDiff = fEnd - fStart;

// convert to rounded minutes

fDiff = Math.round(fDiff / 60);

// get hours from fDiff

fHours = Math.floor(fDiff / 60);

// get minutes less than hour from fDiff

fMins = ((fDiff / 60) - fHours ) * 60;

// format fMins with leading zero

sMins = util.printf("%,302.0f", fMins);

// build display string

event.value = fHours + ':' + sMins;

}

… modified to work in a XFA form.

var cResult = "",

oStart = xfa.resolveNode("TimeIn\\.0"),

oEnd = xfa.resolveNode("TimeOut\\.0"),

Time2Num = function (cFormat, cTime) {

if (cTime === "") {

return "";

} else {

var oTime = util.scand("mm/dd/yyyy " + cFormat, "01/01/1970 " + cTime),

cTZOffset = (oTime.getTimezoneOffset() * 1000 * 60),

cTime = oTime.valueOf() - cTZOffset;

return Math.round(cTime / 1000, 10);

}

},

iStart, iEnd, iDiff, iHours, iMins;

if (!oStart.isNull && !oEnd.isNull) {

iStart = Time2Num("hh:mm", oStart.formattedValue);

iEnd = Time2Num("hh:mm", oEnd.formattedValue);

iDiff = Math.round((iEnd - iStart) / 60);

iHours = Math.floor(iDiff / 60);

iMins = util.printf("%,302.0f", ((iDiff / 60) - iHours ) * 60);

cResult = iHours.toString().concat(":").concat(iMins.toString());

}

this.rawValue = cResult;

Avatar

Avatar
Boost 1
Level 1
NicolasB_
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
NicolasB_
Level 1

Like

1 like

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
NicolasB_
Level 1

25-01-2018

Great!! thank you very much radzmar

here is the xfa form version :  https://adobe.ly/2rIPvIE

I adapted your code to calculate the totals. It works for the days (total-lun, ...) but not for the total of the week (Total.TimeHHMM). Could you help me?

total-lun,... it's ok But now, l'am eoo could you also edit the fields  Total.TimeHHMM,

Total-lun : it's ok

var cResult = "", 

oStart = xfa.resolveNode("TimeHHMM\\.0"), 

oEnd = xfa.resolveNode("TimeHHMM\\.1"), 

Time2Num = function (cFormat, cTime) { 

if (cTime === "") { 

return ""; 

} else { 

var oTime = util.scand("mm/dd/yyyy " + cFormat, "01/01/1970 " + cTime), 

cTZOffset = (oTime.getTimezoneOffset() * 1000 * 60), 

cTime = oTime.valueOf() - cTZOffset; 

return Math.round(cTime / 1000, 10); 

}, 

iStart, iEnd, iDiff, iHours, iMins; 

 

if (!oStart.isNull && !oEnd.isNull) { 

iStart = Time2Num("hh:mm", oStart.formattedValue); 

iEnd = Time2Num("hh:mm", oEnd.formattedValue); 

iDiff = Math.round((iEnd + iStart) / 60); 

iHours = Math.floor(iDiff / 60); 

iMins = util.printf("%,302.0f", ((iDiff / 60) - iHours ) * 60); 

cResult = iHours.toString().concat(":").concat(iMins.toString()); 

this.rawValue = cResult; 

Total.TimeHHMM

var cResult = "", 

olun = xfa.resolveNode("Total-lun"), 

omar = xfa.resolveNode("Total-mar"),

omer = xfa.resolveNode("Total-lun"), 

ojeu = xfa.resolveNode("Total-mar"),

oven = xfa.resolveNode("Total-lun"), 

Time2Num = function (cFormat, cTime) { 

if (cTime === "") { 

return ""; 

} else { 

app.alert(cTime);

var oTime = util.scand("mm/dd/yyyy " + cFormat, "01/01/1970 " + cTime), 

cTZOffset = (oTime.getTimezoneOffset() * 1000 * 60), 

cTime = oTime.valueOf() - cTZOffset; 

return Math.round(cTime / 1000, 10); 

}, 

iStart, iEnd, iDiff, iHours, iMins; 

 

if (!olun.isNull && !omar.isNull && !omer.isNull && !ojeu.isNull && !oven.isNull) { 

ilun = Time2Num("hh:mm", olun.formattedValue); 

imar = Time2Num("hh:mm", omar.formattedValue);

imer = Time2Num("hh:mm", omer.formattedValue); 

ijeu = Time2Num("hh:mm", ojeu.formattedValue);

iven = Time2Num("hh:mm", oven.formattedValue); 

iDiff = Math.round((ilun + imar + imer + ijeu + iven) / 60); 

iHours = Math.floor(iDiff / 60); 

iMins = util.printf("%,302.0f", ((iDiff / 60) - iHours ) * 60); 

cResult = iHours.toString().concat(":").concat(iMins.toString()); 

this.rawValue = cResult; 

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct Reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct Reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

24-01-2018

Your form is an AcroForm and needs to be editied with Acrobat instead LiveCycle Designer.