Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Using an Excel spreadsheet to populate fields

Avatar

Level 1

Hello,

I am trying to create a Form with LiveCycle Designer 8.2 where the user selects one field, and then many fields are automatically populated based on that selection.  For example, the user selects the name of the project they are working on and then project details (such as location, owner, contact, industry, etc.) are automatically filled in with data from an Excel worksheet.

I will be distributing this form to a wide audience, so the data that populates the form will need to "stay" with the form after distribution.  Does the Excel worksheet have to be sent along with the form to make this happen?  Or does the data automatically move with the form after it is sent out?  If not, is there a better way to accomplish such a task?

Examples would be extremely helpful.

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

While you can create a PDF from an Excel spreadsheet the intention is to capture the look and feel of the spreadsheet and not any of the behaviour associated with the spreadsheet. You have to add objects in Designer to make the form interactive. Additionally, you can use Excel data to populate list boxes and drop-downs at design-time but the spreadsheet has no relevance at run-time.

The simplest solution in my mind is to export the data from Excel in a comma-delimited format and use the data to create one-dimensional arrays in Designer. The arrays can be used to populate drop-downs and drive form behaviour.

For example, for a drop-down list called 'projectName' create an initialize event which calls a function on a script object called 'loadProjects'.

// form1.page1.subform1.projectName::initialize - (JavaScript, client)

myScriptObject.loadProjects(this);

The function loads the drop-down with the values from the array called 'projects'. On the 'projectName' exit event, if a value is selected from the drop-down the function 'loadData' is called to populate the fields 'location' and 'owner' based upon the relative array indexes. If a value is not selected from the drop-down the fields 'location' and 'owner' are reset.

// form1.page1.subform1.projectName::exit - (JavaScript, client)

if (this.isNull) {

  form1.page1.subform1.location.rawValue = null;

  form1.page1.subform1.owner.rawValue = null;

}

else {

  myScriptObject.loadData(this);

}

// form1.#variables[0].myScriptObject - (JavaScript, client)

var projects = new Array("","ABC","DEF","GHI");

var locations = new Array("","Sacramento","Ottawa","Fernie");

var owners = new Array("","Anne","Bruce","Carl");

function loadProjects(dropdownField) {

  for (var i=0; i < projects.length; i++) {

    dropdownField.addItem(projects[i]);

  }

}

function loadData(dropdownField) {

  form1.page1.subform1.location.rawValue = locations[dropdownField.selectedIndex];

  form1.page1.subform1.owner.rawValue = owners[dropdownField.selectedIndex];

}

Steve

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

While you can create a PDF from an Excel spreadsheet the intention is to capture the look and feel of the spreadsheet and not any of the behaviour associated with the spreadsheet. You have to add objects in Designer to make the form interactive. Additionally, you can use Excel data to populate list boxes and drop-downs at design-time but the spreadsheet has no relevance at run-time.

The simplest solution in my mind is to export the data from Excel in a comma-delimited format and use the data to create one-dimensional arrays in Designer. The arrays can be used to populate drop-downs and drive form behaviour.

For example, for a drop-down list called 'projectName' create an initialize event which calls a function on a script object called 'loadProjects'.

// form1.page1.subform1.projectName::initialize - (JavaScript, client)

myScriptObject.loadProjects(this);

The function loads the drop-down with the values from the array called 'projects'. On the 'projectName' exit event, if a value is selected from the drop-down the function 'loadData' is called to populate the fields 'location' and 'owner' based upon the relative array indexes. If a value is not selected from the drop-down the fields 'location' and 'owner' are reset.

// form1.page1.subform1.projectName::exit - (JavaScript, client)

if (this.isNull) {

  form1.page1.subform1.location.rawValue = null;

  form1.page1.subform1.owner.rawValue = null;

}

else {

  myScriptObject.loadData(this);

}

// form1.#variables[0].myScriptObject - (JavaScript, client)

var projects = new Array("","ABC","DEF","GHI");

var locations = new Array("","Sacramento","Ottawa","Fernie");

var owners = new Array("","Anne","Bruce","Carl");

function loadProjects(dropdownField) {

  for (var i=0; i < projects.length; i++) {

    dropdownField.addItem(projects[i]);

  }

}

function loadData(dropdownField) {

  form1.page1.subform1.location.rawValue = locations[dropdownField.selectedIndex];

  form1.page1.subform1.owner.rawValue = owners[dropdownField.selectedIndex];

}

Steve

Avatar

Level 1

Thanks Steve, this worked great!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----