Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to Run a JavaScript on Blur trigger in LiveCycle Designer

Avatar

Level 1

Hi there,

I am not a JavaScript programmer, very very beginner.

I found the following script from Google and made a few changes. This will automatically calculate dates and fill in the day fields and it works great on Acrobat DC.

My co-worker wants to use this calculation script in the Adobe LiveCycle ES4, but we do not know where and how to put this script. I do not even know if I can use this script as it is. I tried that copied below script into the "click' and/or 'exit' event on the LiveCycle, but it does not work.

I would appreciated if you could help me how to make it work with LiveCycle

daty14.jpg

========================

var d = util.scand("d-mmm-yyyy", event.value); 
var date2 = this.getField("Date2"); 

var day1 = this.getField("Day1");   
var day2 = this.getField("Day2");
var day3 = this.getField("Day3");   
var day4 = this.getField("Day4");   
var day5 = this.getField("Day5");   
var day6 = this.getField("Day6");   
var day7= this.getField("Day7");   
var day8 = this.getField("Day8");   
var day9 = this.getField("Day9");   
var day10 = this.getField("Day10");   
var day11 = this.getField("Day11");   
var day12 = this.getField("Day12");   
var day13 = this.getField("Day13");   
var day14 = this.getField("Day14");   

var d2 = d.valueOf();  
var dy1 = d.valueOf();  
var dy2 = d.valueOf();  
var dy3 = d.valueOf();  
var dy4 = d.valueOf();  
var dy5 = d.valueOf();  
var dy6 = d.valueOf();  
var dy7 = d.valueOf();  
var dy8 = d.valueOf();  
var dy9 = d.valueOf();  
var dy10 = d.valueOf();  
var dy11 = d.valueOf();  
var dy12 = d.valueOf();  
var dy13 = d.valueOf();  
var dy14 = d.valueOf();  

d2 += 1000 * 60 * 60 * 24 * 13;
dy1 += 1000 * 60 * 60 * 24 * 0;
dy2 += 1000 * 60 * 60 * 24 * 1;
dy3 += 1000 * 60 * 60 * 24 * 2;
dy4 += 1000 * 60 * 60 * 24 * 3;
dy5 += 1000 * 60 * 60 * 24 * 4;
dy6 += 1000 * 60 * 60 * 24 * 5;
dy7 += 1000 * 60 * 60 * 24 * 6;
dy8 += 1000 * 60 * 60 * 24 * 7;
dy9 += 1000 * 60 * 60 * 24 * 8;
dy10 += 1000 * 60 * 60 * 24 * 9;
dy11 += 1000 * 60 * 60 * 24 * 10;
dy12 += 1000 * 60 * 60 * 24 * 11;
dy13 += 1000 * 60 * 60 * 24 * 12;
dy14 += 1000 * 60 * 60 * 24 * 13;

d3 = new Date(d2);  
dd1 = new Date(dy1);    
dd2 = new Date(dy2); 
dd3 = new Date(dy3); 
dd4 = new Date(dy4); 
dd5 = new Date(dy5); 
dd6 = new Date(dy6); 
dd7 = new Date(dy7); 
dd8 = new Date(dy8); 
dd9 = new Date(dy9); 
dd10 = new Date(dy10); 
dd11 = new Date(dy11); 
dd12 = new Date(dy12); 
dd13 = new Date(dy13); 
dd14 = new Date(dy14); 

date2.value = util.printd("d-mmm-yyyy", d3); 
day1.value = util.printd("m/d", dd1); 
day2.value = util.printd("m/d", dd2); 
day3.value = util.printd("m/d", dd3); 
day4.value = util.printd("m/d", dd4); 
day5.value = util.printd("m/d", dd5); 
day6.value = util.printd("m/d", dd6); 
day7.value = util.printd("m/d", dd7); 
day8.value = util.printd("m/d", dd8); 
day9.value = util.printd("m/d", dd9); 
day10.value = util.printd("m/d", dd10); 
day11.value = util.printd("m/d", dd11); 
day12.value = util.printd("m/d", dd12); 
day13.value = util.printd("m/d", dd13); 
day14.value = util.printd("m/d", dd14); 

=========

* I know this can be more simpler, but i don't know how to do it.

1 Reply

Avatar

Level 10

You will have to make a number of changes to get this script working.  Does look like it is meant to be in the exit event, but event.value will become this.rawValue, this.getField("Day1") will probably just become Day1 (depends on the form structure) and day1.value will become day1.rawValue, etc

There is a section in the Designer Scripting Basics reference "Moving from Scripting in Acrobat to Designer" which should help.

There is also a section "Debugging Calculations and Scripts" which shows how to setup Acrobat to use the debugger and show script exceptions.