Multiple Files are Saved. postMessage posts message twice

Product: WebViewer

Product Version: 8.0.0

Please give a brief summary of your issue:
(Think of this as an email subject)

Multiple Files are Saved. postMessage posts message twice

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Hello,

I am not sure if you can help me with this. I have a LWC component for new record. It has Web viewer in that component. When the user clicks on submit button, I create a JSON object to store form data and then call an event listener in config.js that grabs the document from Web viewer, converts it to blob, and calls another event listener with blob data which tells LWC component that blob file is available. After receiving the blob file, LWC calls the Apex function to save form data to Salesforce and blob file to Azure.

This setup works great when you create the first record after landing on Salesforce. After creating the first record, if you try to create another record, listener call from config.js post messages twice so LWC creates two records, one with current form data and file and the second with previous form data and current file.

I am doing something wrong, but I am not able to figure this out. I am not posting messages twice. If I am, then LWC should create two records with same form data and not different form data.

I would appreciate if you guys can assist me with this. Thank you!

Hello Dharmang,

Thanks for your message!

Before we proceed with further investigation I wanted to confirm that we are talking about the same issue - when you are getting these duplicate posted messages, can you check your browser console and see if you have multiple viewer instances (ie. webviewer-1, webviewer-2 etc) from the context switcher drop down (you may need to scroll down, see screenshot below)?

​Thanks,

Thomas

Hey!

Thank you so much for your response. I really appreciate. I did confirm that, and I can only see one WebViewer initialized. Please check the below screenshot.

Thank you!

Thanks for your confirmation - I have reached out via email to investigate this issue further