These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Delete Table line if value is not filled

eddie_irvine
Registered: Apr 23 2008
Posts: 6
Answered

Hi there,

I'm using Lifecycle Designer 8.0 in SAP Netweaver.

My hierarchy looks like this:
|-data
|--BodyPage (binding: none)
|----Positions (Table, binding: $record.IT_ITEM.DATA[*])
|------PositionSection (Section, repeat for each item)
|--------Line1 (Body line, binding: Normal)
|----------...
|--------Line2 (Body line, binding: Normal)
|----------TEXT (Text field, binding: $record.IT_ITEM.DATA[*].TEXT)

As you can see, one table entry consists of both lines Line1 and Line2. I want to delete Line2 if the value TEXT is not filled.
I tried the following (in event "initialize" of Line2), but unfortunately it doesn't work:

var text  = xfa.resolveNode("TEXT");
 
var index = this.index;
 
if (text.rawValue == null) {
  this.instanceManager.removeInstance(index);
}

Can anybody help me with this?
Thanks in advance...

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, you've got a few different things to look at here.

First, "xfa" is the top node of the system. using "resolveNode" at this level won't work with the given SOM path to find a node that's deep in the form hierarchy. Especially if there is more than one "TEXT" node. Please take a look at the SOM reference.

If "TEXT" is a node inside of "Line2", then there is no reason to use the "resolve" node function at all. You can simply reference it directly.

How do you know that the value of text is ever going to be null? Are you really looking for null, or are you looking for an empty string?

The initialize event may not be the right place for this code. The initailize event is called when the form is first loaded into Acrobat. Have you checked to make sure the data is valid when this event is called? Put some console.println statments in your form to find out what's happening when this code executes.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

eddie_irvine
Registered: Apr 23 2008
Posts: 6
First of all, thanks for your reply!

Ok, I see that I've a lack of some basic knowledge in this area...

I just tried this now, but it doesn't work either:
----- data.BodyPage::ready:form - (JavaScript, client) ---------------------------------------------var text  = resolveNodes("xfa.form.data.BodyPage.Positions.Section.Line2[*].TEXT"); for (var i = 0; i < text.length; i++) {var Sname  = xfa.form.data.BodyPage.Positions.Section._Line2.name;var nCount = xfa.form.data.BodyPage.Positions.Section._Line2.count; xfa.host.messageBox("TEXT: " + text.item(i).rawValue); if (text.item(i).rawValue == null) {xfa.host.messageBox("Sname: "  + Sname);xfa.host.messageBox("nCount: " + nCount);xfa.form.data.BodyPage.Positions.Section._Line2.removeInstance(nCount - 1);}}

One thing I realized is, that the data binding has a big influence on the processing of the code.

I tried everything regarding data binding, but I'm not sure how to do it correctly.... How would you do the data binding for my example?
I want to display Line1 and Line2 for each entry in my table. And if the field TEXT is not filled, Line2 should not be displayed.

Is the choden event correct in this case?

Thanks in advance...
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Take a look at the recorded eseminar. It covers a lot of the details you need

https://admin.adobe.acrobat.com/_a200985228/p87746471/

You're code looks good, you don't need to use absolute SOM paths, but as long as the paths are correct it should be ok. What is it about this that is not working? Please be specific.

I think your binding is probably ok. If you setup the DB in the Data View Window and connected it to your fields, then it should be fine.

The way to get started on your form is to remove all scripting, setup the binding, and then test it out. If all the data loads and creates all the instances of Line2 that are required, then you've got a solid starting point.

Next, add console.println() statments to all the events that you think you might need to use. Printout the value of the data and any other information that is necessary. Then look in the Console window to see what happened. Don't use the message box function. It blocks processing and might mess up the real event and data merging order.

Once you've done this you should have a good idea of what event is best.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

KathrynGZ
Registered: Apr 15 2008
Posts: 35
Would simply hiding the table row be an option for you? I just did this on a form yesterday--it is pretty simple and it worked well. In my script, hiding the row is based on a variable, but you could adapt it to your situation. I put this Formcalc script in the initialize event of the form:

if (varJobTitle == "Sales Professional") then
form1..Table1.Row[2].presence = "hidden"
endif

HTH,
Kathryn
eddie_irvine
Registered: Apr 23 2008
Posts: 6
Thanks for your answer...

I've no solved the issue:
----- data.BodyPage.Positions.Section.Line2.TEXT::ready:form - (JavaScript, client) ---------------- var text = this.rawValue; var index = parent.instanceIndex;if (text == null) {parent.occur.min = "0";parent.instanceManager.removeInstance(index);}

The problem was, that the scripting on my form didn't work correctly. Message boxes were shown, but the removal of nodes was not possible...

It was an SAP issue, I had to change something in that area. It cost me a lot of nerves!