You are viewing limited content. For full access, please sign in.

Question

Question

Checking if a field is empty and assigning value from another field

asked on February 13

I have the below javascript entered in Forms Version 12.

I'm pulling up the form in Chrome version 144.0.7559.133.

The console is displaying: ERROR SyntaxError: Unexpected identifier 'myFieldValue'.

I'm not seeing the syntax error. Can anyone see what I'm missing? Is it the myFieldValue.IsEmpty()?

Not sure if I'm allowed to use that in LaserFiche.

 

//Function to copy Last Name at Birth to Last Name if Last name is empty
//You just need to pass in the field ID Number of Last name at birth and 
// fieldId of Last name.
function UpdateLastName(fieldIDNumber, fieldIDNumbertoCopy)
{
  
  //Retrieve all fields with that indicated ID.
  var myField = LFForm.findFieldsByFieldId(fieldIDNumber);
  
  var myFieldValue = LFForm.getFieldValues(myField);
      
    //Loop through all field values if 2 or more were found,
    //and call the toCapitalize function.
    if myFieldValue.IsEmpty() {
        LFForm.setFieldValues({fieldId: fieldIDNumber}, {fieldId: fieldIDNumbertoCopy});
    }    // if myFieldValue.IsEmpty()
}   //End of function UpdateLastName(fieldIDNumber,fieldIDNumbertoCopy)...

LFForm.onFieldBlur(UpdateLastName(7,6),{fieldId: 6});
LFForm.onFieldBlur(UpdateLastName(7,6),{fieldId: 8});

 

Thank You

0 0

Replies

replied on February 16

The "if" statement/condition needs to be inside ().

 if myFieldValue.IsEmpty() {

needs to be

 if (myFieldValue.IsEmpty()) {

 

0 0
replied two days ago

Thank you, Bert.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.