Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Added action is disabled in XML source on a PDF form

Avatar

Level 1

Hello, I am working with AEM Designer to map a PDF form and use actions on the form.  I added two text field objects and bound data to each of them.  Then I added an action to set the value of one of the fields to null if the other field is not empty.  I am able to save the action and do not get any errors, but upon previewing the form, the action does not work.  In the XML source, I noticed that the action was added as a comment:

//+ Type: Action
//+ Result1: SetFieldValue("$Node2","tonull","")
//+ Node2: FormType[0].Page1[0].Make[0]
//+ Node1: FormType[0].Page1[0].Vin[0]
//+ Condition1: TextField("$Node1","notempty","")
//+ ActionName: Vin.exit
if ((this.resolveNode("$").rawValue != null && this.resolveNode("$").rawValue != "")) {
this.resolveNode("Make").rawValue = null;
}
//-

Can anyone tell me why the action was commented out?  This is the first time I am working with actions so I am wondering if maybe there is some other form setting that I am missing?  Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi, it is NOT commented. // are line comments and not comment ranges. The actual code line is active. When I do the same thing here it works as expected. The way this is done is that on exiting the field in the action (here Vin) the code gets executed. So you must exit Vin before you see the result.

Kosta_Prokopiu1_0-1616488774902.png

Before Exit:

Kosta_Prokopiu1_1-1616488839533.png
After Exit:

Kosta_Prokopiu1_2-1616488869525.png

The action:

Kosta_Prokopiu1_3-1616488895007.png

 

 

View solution in original post

6 Replies

Avatar

Correct answer by
Employee

Hi, it is NOT commented. // are line comments and not comment ranges. The actual code line is active. When I do the same thing here it works as expected. The way this is done is that on exiting the field in the action (here Vin) the code gets executed. So you must exit Vin before you see the result.

Kosta_Prokopiu1_0-1616488774902.png

Before Exit:

Kosta_Prokopiu1_1-1616488839533.png
After Exit:

Kosta_Prokopiu1_2-1616488869525.png

The action:

Kosta_Prokopiu1_3-1616488895007.png

 

 

Avatar

Level 1

Thank you for the clarification.  In that case, perhaps I should provide more context because it is still not working for me.  We build static PDF forms in AEM Designer that get rendered through AEM servers with XML data based on a data schema.  For this test, I mapped a form with the two fields and added the action on one of the fields.  When I do a Preview PDF from within AEM Designer, the action does not work.  I even tried changing the order of the fields in the hierarchy and it still did not work.  Here is my action:

TK0215_0-1616529863327.png

 

And here is the result in Preview PDF:

TK0215_1-1616529903433.png

 

Any thoughts on why it does not work in Designer?

 

Avatar

Employee
As I mentioned in response to your PM, if this is a print PDF the action will not work. If this is interactive PDF then check your Preview settings under File - Form Properties - Preview to be Preview Type Interactive Form. If this is indeed a Print/static PDF you need to approach this differently.

Avatar

Level 1
Yes, this is a print/static PDF. Do you have any recommendations on how to approach it differently? The end goal is to null out/not show certain fields based on the data that populates other fields.

Avatar

Employee

@TK0215 Different situation - it is a print PDF that you fill based on incoming data. Here my assumption: The data can contain both data values, if it does then VIN shall take precedence and clear field make. You have to remove the current action as it will not help you. A simple form with 2 text field. I simulate your data by using the Default value for both fields. In the initialize event of the field VIN I check the content and empty Make if it is filled.

Kosta_Prokopiu1_3-1616597456408.png

 

Preview as Print, no logic applied, both fields show content

Kosta_Prokopiu1_1-1616597256238.png

With logic in Initialize of Vin


if (this.rawValue != null && this.rawValue != "") {
Make.rawValue = null;
}

Kosta_Prokopiu1_2-1616597353120.png

If Vin is empty then

Kosta_Prokopiu1_4-1616597487079.png

 

 

 

Avatar

Level 1
This did the trick. Thank you very much for your help!