Wednesday, 19 April 2017

Calculation on dynamically added rows in a Table.

Among many features that PDF provides, auto calculation of form fields is a very useful feature. Apart from the usual mathematical calculations, this feature can be exploited to calculate table rows based on the data at run time.

Use Case
Consider a scenario where the data is generated and fed to the table. The table must accommodate the incoming data dynamically at run time. And you determine that you must add few more rows in the table as per user requirement at the same time.
How will we calculate to reflect the dynamic objects and how to reference these values?  
This article will help you to accomplish the task.

We use the following script:
FormCalc Script: sum(Table1.Row1[*].total.rawValue)

There are two essential things to be kept in mind to make the script work:

  1. Choose the script language as FormCalc in LC Designer. By default, it is set to JavaScript.
  2.  The FormCalc function sum()  is simple to use. Make sure you know the object (that is, either the row or field) that is getting added dynamically. The [*] symbol is appended to the row which is getting repeated or with the field name if required.
In our use case example, only the row is repeating. So, we have not provided any value for the field.

For additional queries, please send your form to

Monday, 7 September 2015

Email Submit Restrictions

1. To apply restriction in a form which needs to pass before submit.
2. If the user cancels the submit process then perform post submit operation and validate again.

Verifying the restrictions is easy in the form, but to capture the control after user clicks on Submit Button is tricky.

In my example, I am verifying the Phone Number on submit and hiding the Submit Button itself.
The scenario is that the form can only be submitted once.

However, if the user clicks on Submit Button and cancel the draft email for any reason then the whole process should be nullified and Submit Button should remain active.

This can be done by using the try catch block. And after capturing the specific exception of user cancelled operation, we can perform post submit operation.

Submit Cancelled

var eid = "";
var sub = "This is a dummy Subject Line";
var bdy = "Sample Body";

if(TextField1.rawValue == null || TextField1.rawValue == "" || TextField1.rawValue.length != 10)
app.alert("Please enter correct phone number");
if(TextField1.rawValue.length == 10)
this.presence = "hidden";{cURL:"mailto:" + eid + "?subject=" + 'Anoop &amp Singh' + "&body=" + bdy ,cSubmitAs:"PDF",cCharset:"utf-8"});


if(e.toString() == "RaiseError: User canceled operation.")
this.presence = "visible";


Monday, 31 August 2015

Convert Numbers into Words

WordNum is the function which returns the English text equivalent of a given number.

For Example:
WordNum(123.45)One Hundred and Twenty-three Dollars
WordNum(123.45, 1)One Hundred and Twenty-three Dollars
WordNum(1154.67, 2)One Thousand One Hundred Fifty-four Dollars And Sixty-seven Cents
WordNum(43, 2)Forty-three Dollars And Zero Cents
WordNum(Amount[0], 2)
This example uses the first occurrence of Amount as the conversion number.
 However, there is a limitation in this fuction. It only converts the two decimal values and if you want to English conversion for more than 2 decimals then you need to use the JavaScript to modify the function.
This is required in case of currency conversion for example Omani Rial, where 3 decimal values are acceptable.

Note: This function runs in Formcalc language so all coding needs to be done in FormCalc only.

Number To Word

if ($.rawValue == "OMR") then
var last = right(TextField1,3)
var part1 = Concat(WordNum(TextField1), " rials And ")
var part2 = Concat(WordNum(last) , " baisa")
TextField2.rawValue = Concat(part1 , part2)


Wednesday, 26 August 2015

Radio Button as mandatory field

How to make the radio button group as required.

By default, LC Designer doesn't validate the NULL value of the Radio Button Group as Required Field. We need to use JavaScript to implement the logic.
In my example I used a button to first validate the Radio Button Group and if it is not NULL then it sends an email.

Radio Button Required

if(RadioButtonList.yes.rawValue == null && == null)
app.alert("Please select the option");

var eid = "";
var sub = "test subject";
var bdy = "Sample Body";{cURL:"mailto:" + eid + "?subject=" + sub + "&body=" + bdy ,cSubmitAs:"PDF",cCharset:"utf-8"});


Tuesday, 25 August 2015

Cursor focus on specific field

To move the focus on the specific field.

Many a times, we need the cursor to move to specific field based on our requirement. The most common scenarios are - validation of fields and Tab Order.

Use the following script to focus.


if (event.fieldFull) {