cancel
Showing results for 
Search instead for 
Did you mean: 

offline form - lock form when submit by email

jlsim
Explorer
0 Kudos

Hi Gurus,

Need your expert advice on this.

I am creating a offline form with a standard "Submit by email" button. After user filled in all the value, and clicked on the "submit by email" button, the standard validation will check for required fields and if everything is fine it will attached this pdf in an email.

The problem is i want the pdf that get attached in the email as readonly, and with the "submit by email" button hidden. Any idea how do i archive this?

I am thinking of using the below script to lock the fields:

for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++)

{

var oFields = xfa.layout.pageContent(nPageCount, "field");

var nNodesLength = oFields.length;

for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++)

{

oFields.item(nNodeCount).access = "readOnly";

}

}

But the problem is I can't find a suitable event to trigger it.

For example:

1. if i put at the "click" event of "submit by email" button, the fields will get lock even the empty field validation failed, as the click event is trigger before the validation.

2. If I put at the "presave" event, it locks the fields only after the empty fields validation is successfully done. But it will lock the fields when user trying to save the pdf doc, which i dont want.

Any idea will be very grateful.

Accepted Solutions (0)

Answers (3)

Answers (3)

jlsim
Explorer
0 Kudos

Hi Sai,

This is a very helpful answer. Thankyou very much.

I was thinking to use standard empty field validation, but looks like i don't have the choice but to write my own validation.

But now i am facing a problem where by the required field are highlighted in red even after i entered, and once i lock the form it appeared in there as well. I will open a new thread on this one.

Former Member
0 Kudos

Cheers Mate.

jlsim
Explorer
0 Kudos

Thanks for the reply.

I have tried that approach before, but i am facing a problem where by when the "submit by email" is clicked, the click event is trigger before the standard required fields validation is run. This causes the flag to be set even in the case where by the validation is failed. Therefore locking the form and user can't fill up the required empty fields.

Do you face this problem with this approach?

Is there a way to only lock the form when the required fields validation is a success.

thanks

Former Member
0 Kudos

Hi Mate,

That shouldn't be a problem at all.

See my code below for a submit event.


if(validateMandatory() == true){
  if(xfa.host.messageBox("Are you sure... \nDo you want to Submit the form...? ", "Submittion Confirmation", 2,2) == 4){
      GM_INTAKE_STRUCTURE.sfFooter.hiddenFields.EDIT_FLAG2.rawValue = 3; // finally sent to Assessor so no more edit.
      // DO NOT MODIFY THE CODE BEYOND THIS POINT - 820.20090409114549.542109.508401 - SubmitToSAP.xfo
          ContainerFoundation_JS.SendMessageToContainer(event.target, "submit", "", "", "", "");
      // END OF DO NOT MODIFY
  }
}
example 
function validate(){
 var msg = "";
  if(x.rawValue == null)
	msg = "please fill x value";
  if(msg != null){
     xfa.host.messagebox(msg);
     return false
  } else{
     return true;
  }
}

let me know if you need explanation of the above code.

Cheers,

Sai

Former Member
0 Kudos

Hi Mate,

I have done it in several forms in following way.

I have a flag field say X, default value 0

and a submit to emai button B both of them are in a subform sf.

On click event of the button I set the flag to 1.

User clicks button the form is then mailed accross.

now on the form ready event. check the flg field.


if(flag.rawValue == 1){
  form.sf.presence = "hidden";

// making readonly to the entire form set the access to the heighest subfom all the childs in that will inherit the property.
form.sf1.access = "protected"; // or use readOnly.
upto all the other sub forms.
}

hope this helps,

Cheers,

Sai