Сreate a file from a template

cancel
Showing results for 
Search instead for 
Did you mean: 
taibek
Active Member

Сreate a file from a template

I found this code to create a file from a template


      // Data to fill in the template var num = "42"; var buyer = "Acme, Inc"; var sum = "700$";  // Get template file var tempFile = search.findNode( "workspace://SpacesStore/262981fb-e141-43bd-ac63-9b8199eb1077" ); // Get target folder var folder = search.findNode( "workspace://SpacesStore/ef296491-90ff-4427-a06a-31fd4abf4245" ); // Name of new file to be created var name = "Invoice " + num;  // Create string with data to fill the template. // Parameters names (number, company, amount) match the names in the template. var data = jsonUtils.toJSONString( {"Number": num, "CustomerName": buyer, "Amount": sum} );  // Create new file template.generate( tempFile, folder, name, data );

But it does not work says not found
jsonUtils and
template.generate

Tell me how to fix this or how to create a file from the template correctly

2 Replies
mrks_js1
Established Member II

Re: Сreate a file from a template

where is the script with this snippet? what version of alfresco are you using?

taibek
Active Member

Re: Сreate a file from a template

I'm new in alfresco. I try to write such a script, but it does not work.Im using 5.2 version.I want to create file with template at ui of process