cancel
Showing results for 
Search instead for 
Did you mean: 

Understanding adobe form behavior for Business ByDesign

former_member689468
Participant
0 Kudos

Hello all,

I had a fairly simple requirement.

For customer invoice adobe form customer asked me, if an item has anything written in the customer information, then instead of item description, the customer information text should be written on the form when previewing.

This is my code and I am pretty sure it works okay:

var i = this.parent.Cell1.rawValue / 10 - 1;
var j = 0;



//this.rawValue = xfa.resolveNodes("CustomerInvoice.Item[" + i + "].TextCollection.Text[*].TypeCode").length;

var tekstovi = xfa.record.CustomerInvoice.resolveNodes("Item[" + i + "].TextCollection");
var retci3 = tekstovi.length;


if ( retci3 > 0 ) {
	
	for ( j = 0; j < retci3 ; j++ ) {
		
		
		var typecode = xfa.record.resolveNode("CustomerInvoice.Item[" + i + "].TextCollection.Text[" + j + "].TypeCode").value;
		
		
		
		if ( typecode == 10024 ) {
			
			var tekst = xfa.record.resolveNode("CustomerInvoice.Item[" + i + "].TextCollection.Text[" + j + "].ContentText");
			this.rawValue = tekst.value;
		}
	
	}
}	
However, when this code is active I get all sorts of crazy outputs. When there is nothing entered for a certain item, that item would normaly display Description, as intended and as is the binding for that field. But when there is something entered for a ceratin item then nothing would be displayed, just empty cell.I tried a bilion things that didnt work. Then when I was debuging for a thousanth time one of my examples, I noticed that if I put another table and I bind the item text collections then suddenly my code works and everything is displayed.

I just hide the top table which has item->text collection->content and then suddenly my code works, and it is as if finally the notes from the invoices come to the form.

I dont understand the behavior of SAP Business ByDesign and my adobe form in this case. It is as if anything that is not put as binding somewhere on the form will not be able to be read by javascript ? Is this how the forms behave and I only just realised it or is there something specific for this case ?

I need to understand how this thing works for future references and to minimize time lost on such simple things...

Hopefuly someone understands this and can explain, thank you in advance

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member183363
Active Contributor

My experience of the data in LiveCycle is that the tables 'eat' the information after it's displayed; for example if you put two identical tables in the same form, one after the other, only the first one will show the information; it's like the items disappear from the schema after they're used. Without looking at your form I can't say whether that's the cause or not; my advice is to look at existing scripts for anything that might interfere. If you preview in LiveCycle and then go to Window > Report, then the Log tab, you may see scripts that are breaking which may also affect it.

former_member689468
Participant
0 Kudos

Yes I noticed that also. That might be a reason because whenever I edit a standard form I tend to just hide parts I dont need - in this case that was the original table. I always put my new tables before the standard tables in hierarchy so the data doesnt get "eaten" as you so well put it, but in this case who knows if somehow the binding of the notes in the standard table took priority and then it wasnt displayed until I bound them in a new table again. Because when I put that new "shadow" table after my main table then the notes will not be displayed. Crazy...

former_member183363
Active Contributor

You have the line:

var tekstovi = xfa.record.CustomerInvoice.resolveNodes("Item[" + i + "].TextCollection");

What you want to do is change that to 'TextCollection.Text[*]', as it's that list you're looping through. Here's some code I used to get a note from an item:

if (xfa.resolveNode("xfa.record.CustomerInvoice.Item[" + this.parent.index + "].TextCollection") != null)
{
	var allItemNotes = xfa.resolveNodes("xfa.record.CustomerInvoice.Item[" + this.parent.index + "].TextCollection.Text[*]");
	for (var i = 0; i < allItemNotes.length; i++)
	{
		var itemNote = allItemNotes.item(i);
		var type = itemNote.TypeCode.value;
		//if (type == "10024") //10024 == Customer Information.
		//{
			var noteRow = this.parent._rowNote.addInstance(true);
			noteRow.txtNote.rawValue = itemNote.ContentText.value;
			//break;
		//}
	}
}
former_member689468
Participant

Thank you mr Lewis. Seeing your name under answers always brightens my whole day, you always have good suggestions and I really appreciate it.

My code probably can be better than it is - but it works. It either puts out Item.Description which is under object binding, or if there are notes for relevant items, then it displays the note. I had at least 50 iterations on this code, and I am 99% sure I tried what you suggested but it didnt give me the wanted result.

The biggest question mark for me is, why it seems to only work after I add another "shadow" table which is hidden and in that table I bind Item.TextCollection.Text. As if the javascript itself can not read the content of the notes unless they are explicitly put as binding for an object on the adobe form and that makes no sense to me so I am trying to find my mistake or figure out if this is how its supposed to behave.

I will definetly try your suggestions and see if it works without the need of binding the item notes somewhere in the adobe form. Will post the results after I do it.

But even if it does, it will still be very confusing to me why my code suddenly worked once I created that second table...