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.

Delete a row instance with a custom message box

Avatar

Level 1

Hello all

  I am a new developer and I hope I can get some help from this forum. I took a three day training for Lifecycle ES designer and understand how the forms work but I am new to JavaScript. I am building a form where I can successfully add a table in a sub form and delete one. The issue I am having is setting up a message and checking for the instance so that a user gets my message box instead of the default that Adobe generates when the script is run for the first signature block table that needs to be in the document by default. The min box property for the table has a 1 in it.

Here is my script in the button.

form1.Page1.Page2subform.SignatureBlock.clientSignatureBlock.buttonSubForm.removeClientSignature::click - (FormCalc, client)

    clientSignatureTable.instanceManager.removeInstance(1);

This script works just fine and so is my add button.

I can't figure out how to design an if statement that says

If instance > then default instance then


delete instance


else


show $host.messageBox("Cannot delete client signature block.");

I will truly appreciate some help. Thank you. Deepa

default delete table error message.jpg

3 Replies

Avatar

Former Community Member

The deleteInstance method requires that you pass the index of the subform that you want to remove. The indexes are 0 based so you are asking to remove the 2nd instance and there is none so the script fails. You can get a count of the subforms by using the count property ...this returns a 1 based number of subforms. So .......

if (clientSignatureTable.instanceManager.count != 1){

     remove subform .....

} else {

     xfa.host.messageBox("Your message here ....")

}

Hope that helps

Paul

Avatar

Level 1

Thank you Paul for this information. Thsi was helpful. I got some help from another consultant who helped me out. Question I have for you or others is: Is there any training specific to Livecycle ES Javascripting that I can take? Do you know of anyone who offers that? I need to understand the basics of that. From what I understand the Javascripting in Livecylce is not the same as regualar Javascript. I will appreicate any help pointing me to a good resource. Thank you. Deepa

Avatar

Former Community Member

There are training courses available from Adobe partners. How you find out when and where they offer these courses I am not sure about, but I woudl start at the Adobe web site and look for Training.

On your second point .....Javascript is javascript ...LC javascripting is the same as regular javascript. The part where people struggle is that LC has extensions specific to that product. So there is an event model and an obejct model that needs to be understood to be good at javascripting in LC.

Make sense?

Paul