✨ Community just got smarter! Our all-new AI search is live! ask anything in the search bar, get instant answers.

Having a unique filename generated, when creating a document via a CRM script

lock
push_pin
done
Beantwortet
0

Hi,

I have created a script that generates a quote order confirmation from a sale with a quote.  The customer needs to produce a number of different documents from the quote lines when the quote is sold, but out of the box, only one order confirmation document can be created at the point the Place Order button is pressed (by selecting the "Send order confirmation via e-mail" option).

I have created other order confirmation documents in SuperOffice for things such as Works Orders, and then use "quoteAgent.GetOrderConfirmation(quoteVersionId, confirmationTemplateId)" to get a Base64 string of the document, and create a document in SuperOffice based on this Base64 string.

It all works well, the script runs on the Task Menu and shows a form with a list of all available Order Confirmation templates, and then creates a document based on the selected template.

The one issue though is that SuperOffice does not seem to create a unique filename for each of the documents generated via the CRM script, so if the same document template is generated twice for the same quote (filename is based on the template type and quote number), they both get the same filename, and both documents in SuperOffice are linked to the same physical file.  This also means that when one of these documents is deleted in SuperOffice, you get an error opening the other document, as the physical file linked to this document is now deleted.

I have worked around the issue by adding a datetime stamp at the end of each filename, so that it is always unique, but this is not ideal, as when the user uses the "Send as email" option for this document, the file is attached using the messy filename (instead of the better solution which the legacy Outlook Mail Link does, of generating a new clean filename based on the document subject).

If you use the doc.SetName or doc.SetHeader, some tidying of the filename is performed, I.E. if I set the filename to "Works Order Sheet - Quote 10084 v2.pdf", it will set the filename to "works-order-sheet-quote-10084-v2.pdf", but you would think that if this filename was already in use in that SO_Arc folder, that it would rename it to something like "works-order-sheet-quote-10084-v2[2].pdf".

I have looked to build a search engine to see if the filename is already in use and then increment a number at the end of the filename, but only if the original filename has been used before.  However the text stored in the name field is sometimes with spaces, sometime with dashes, but either way the actual filename created is always with the dashes, so this is inconsistent.

Is there any simple way with the Document Agent, to specify a desired filename for a document, and have SuperOffice automatically adjust this, to keep the basic format of your filename, but ensure the filename of the file created in unique to that SO_Arc folder.

Many thanks,

Trevor

12 h, 11 m vor | 02:29 PM

Alle Antworten (0)

Antwort hinzufügen