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

Question

Question

Invalid values. Please check the JavaScript on the form.

asked two days ago

Hi,

I've got a Cloud BP that tries to save a form with current process data. The form has some LFForm JavaScript  that is setting default address field values. The form has just this JS code, nothing else.

JS Code: 
LFForm.setFieldValues({fieldId: 16}, {address1: "1234 New Road", address2: "Suite 150", zipcode: "99999", city: "City", province: "ST", country: "USA"});

The form shows the values properly, but the Save to Repository task stops with this error:

"Failed to generate a document from the form: Error: Invalid values. Please check the JavaScript on the form."

Any idea why this might occur?

0 0

Answer

APPROVED ANSWER SELECTED ANSWER
replied one day ago

The new designer is unique from classic in that it actually runs the JavaScript on every process step including save to repository. In a save to repository step forms are marked readonly so attempting to set them via JS will throw an error. You should (always) handle errors gracefully in cases you are modifying form state. I am actively updating our documentation to provide better examples of this. You can also use the LFForm properties to determine the status of the form 

try {
  LFForm.setFieldValues({fieldId: 16}, {address1: "1234 New Road", address2: "Suite 150", zipcode: "99999", city: "City", province: "ST", country: "USA"});
} catch (err) {
  console.warn(err)
}

// OR 

LFForm.setFieldValues({fieldId: 16}, {address1: "1234 New Road", address2: "Suite 150", zipcode: "99999", city: "City", province: "ST", country: "USA"})
  .catch(err => console.warn);

// Best way
if (LFForm.isReadonly === false && LFForm.isDisabled === false) {

  try {
    LFForm.setFieldValues({fieldId: 16}, {address1: "1234 New Road", address2: "Suite 150", zipcode: "99999", city: "City", province: "ST", country: "USA"});
    // form logic
  } catch (err) {
    console.warn(err)
  }
}

 

0 0

Replies

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

Sign in to reply to this post.