Accessing detail field inside text script

Hello Team

I have nested detail table like:

image

I would like to access CurrentPage and TotalPage fields value from my template text script.

I would like to check if CurrentPage == TotalPage then set FormatedBalance amount amount, otherwise display word CONTINUE.

Any idea how to achieve that?

Can you let us know please what your Text Script is targeting specifically?

As in regards to your question: An option is to expand your Text Script to a Standard Script and to apply something similar to the following JavaScript code to your Standard Script:

results.each(function (index) {
	var currentPage = "",
		totalPage = "",
		formattedBalance = "",
		result = "";

	if ("page" in record.tables) {
		if ("Heading" in record.tables.page[index].tables) {
			currentPage = record.tables.page[index].tables.Heading[0].fields.CurrentPage;
			totalPage = record.tables.page[index].tables.Heading[0].fields.TotalPage;
		}
	}

	if (currentPage !== "" && totalPage !== "") {
		if (parseInt(currentPage) == parseInt(totalPage)) {
			formattedBalance = record.tables.page[index].tables.Heading[0].fields.FormattedBalance;

			result = formattedBalance;
		} else {
			result = "CONTINUE";
		}
	}

	results[index].html(result);
});

Note: Please note that I am only checking the first record in the detail table “Heading” (see Heading[0] in record.tables.page[index].tables.Heading[0].fields.CurrentPage, for example) and that I assume that the value of the record fields “currentPage” and “totalPage” a string containing an integer concern in the above sample of JavaScript code.

My text script is targeting some DIV with ID @Marten

Thank You Marten.

This set continue but I need to do the checking for each page. (Each detail)

So when I am on page 1 of 2 - want to display CONTINUE.
When I am on last page (2 of 2) then display proper amount.

Can we check each detail field value? Or maybe its easier way doing this

Would it be possible for you to share your current DataMapper configuration and Template… by private message, perhaps?

I solved this problem in data mapper. Thanks

1 Like

Can you let us know please how you were able to solve the issue at hand? Can you share a brief summary, for example?

Because in my case this amount always is same. (So we work around this)

You can use 2 items in output preset 1 text CONTINUE and 1 amount.
Each elements will has different condition.

You have to also promote/add amount fields into Job Preset to be visible inside output preset

Also we are able to use post pagination script for doing this. So in that case no need to use this in output preset.

1 Like