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

Question

Question

Laserfiche cloud Modern designer - Save to repository error - Failed to save to repository. The document or attachment was unable to be generated - please retry service. If issues continue, please open a support case. [LFF4121-FormGenerationFailed]

asked on May 8, 2024 Show version history

Hello friend,

I am using modern designer form within cloud enviornment.

For testing right now I have two fields ; one is single line and second if custom html.

I have written one small JS as well.

When I submit the form within save to repository it shows error like "Failed to save to repository. The document or attachment was unable to be generated - please retry service. If issues continue, please open a support case. [LFF4121-FormGenerationFailed]"

Note: When I remove the JS its working fine but we need to write many JS code.

 

Thanks,

Pratik

 

 

 

Javascript.png
Form.png
Javascript.png (20.41 KB)
Form.png (25.51 KB)
0 0

Answer

SELECTED ANSWER
replied on May 9, 2024

JavaScript in the new form designer is unique from the classic designer in several ways. First, JavaScript in the new designer does run on save to repository tasks. This makes it very powerful but, as you noticed, problematic if errors are not handled in code. Second, many of the LFForm APIs return promise values. Especially those that are performing write operations on the form like show/hide/setFieldValues. The latter is a very important detail because although you may be able to get away with not 'awaiting' these promises if you expect linear flow of your forms you need to handle the asychronous nature of these APIs as well as gracefully handling errors when they occur. To keep your script simple, I would recommend the following code/scaffold that I have tested to work on form load and save. You will notice I've wrapped all code into a 'main' function that is defined as an async function. Now I can await any relevant APIs that require it. Within that, all code I need to write will be within the try branch of the try/catch so I can handle errors. Now as your script grows in complexity you may want to handle errors at the individual API level, but I will let you explore that with the links I have provided. Let me know if you have any other questions!

const main = async () => {
  try {
    await LFForm.setFieldValues({ fieldId: 2 }, "Any value");
    // any more code goes here
 

  } catch (err) {
    console.warn(err)
  }
}
main()

 

0 0

Replies

replied on May 9, 2024

Hello Zachary,

Yes. I have tested and it running as expected.

Kindly suggest that if we have many line of code inside the JS ; should I write that code inside the try block ?

Also do we need to write "await" in each line of code ?

 

Thanks,

pratik

 

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

Sign in to reply to this post.