Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Add instance on Read only field issue

Avatar

Level 2

I have a subform with two fields , one a date field to capture current system date and time and another is a Text field for some comments.

Then there are two buttons ,one for Adding the instance for these two fields and another is a Save button which makes these two fields

The requirement is that once both the fields are filled with data and i click on save button, the fields should become read only ,however when i click on the add instance button the instance is added successfully but the save button click is not making the new instance read only.

The Code for Add Instance Button is :

"New1.FileNote.instanceManager.addInstance(true);

xfa.form.recalculate(true);"

The code for Save button to make the fields read only is :

New1.FileNote.DateTimeField101.access = "readOnly";

New1.FileNote.TextField37.access = "readOnly";

Please guide me as I am totally blank on how to code the same..Have a rough logic of using a for loop with index of the Add Instance but not getting the way out for the code.

Thanks a lot for any help and guidance.

3 Replies

Avatar

Former Community Member

If FileNote is the repeating item New1.FileNote.all.item({insert number here}).DateTimeField101.access = "readOnly";

Avatar

Level 2

Hi Steve,

Thanks for your reply..I made it happen using the for loop with Index and resolve node. However there is another issue which occured after that..I have a date/time field in that repeating subform instance.

The run time property is set to Current Date/Time. Now the issue is whenever i click on save, form.recalculate instance changes the existing time value in the previous subbform instance as well

Is there a way to retain the existing value in the field of the previous instance ??

Regards

Kapil

Avatar

Former Community Member

You could put it in the calculate wrapped in an if checking if not readOnly.