web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

upload file to sharepoint, from temporary url

(0) ShareShare
ReportReport
Posted on by 60
good,

Currently I generate a template by code, this template generates a URL for me, that URL only lasts for a certain time, so if the user takes a long time to open, he will not be able to download the file.

This is why I need that the file that is downloaded from the temporary URL can be uploaded to SharePoint and is available for as long as necessary.

It can be done in a native and "functional" way, I need to do it by code.

const str templateName = "XXXXservicio"; //template uploaded in the system
DocuTemplate template = DocuTemplate::findTemplate(OfficeAppApplicationType::Word, "XXXXservicio");

// Ensure the template was present
if (template && template.TemplateID == templateName)
{
	Map filtersToApply = new Map(Types::String, Types::Class);


	ExportToExcelFilterTreeBuilder filterBuilder = new ExportToExcelFilterTreeBuilder(tablestr(XXXXWorkerEmployeeEntity));
	FilterCollectionNode filterString = filterBuilder.and(filterBuilder.companyFilter(),filterBuilder.areEqual(fieldstr(XXXXWorkerEmployeeEntity, PersonnelNumber), "000713"));

	filtersToApply.insert(tablestr(XXXXWorkerEmployeeEntity), filterString);

	// Generate the workbook using the template and filters
	DocuTemplateRender renderer = new DocuTemplateRender();
	str documentUrl = renderer.renderTemplateToStorage(template, filtersToApply);//TEMPORARY url that I get


	// Pass the workbook to the user
	if (documentUrl)
	{
		info(strformt("url %1",documentUrl));
   
	}
	else
	{
		error(strFmt("@ApplicationFoundation:DocuTemplateGenerationFailed", templateName));
	}
}
else
{
	warning(strFmt("@ApplicationFoundation:DocuTemplateNotFound", templateName));
}


natively it is possible to do so:

pastedimage1611107307101v1.png

pastedimage1611107352197v2.png
once saved it gives me another URL, this one is long-lasting.


pastedimage1611107506791v3.png

i need the last url. thanks
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,795 Most Valuable Professional on at

    If you look into code, you'll see it tries to update files to SharePoint and it uses blob storage only if the attempt with SharePoint fails. This happens in ExportToExcelStorageHelper::uploadExportStream(), which is called from DocuTemplateRender.renderTemplateToStorage(). You can see that there is setup that would have to be in place, therefore one of your options is simple do the setup.

    Alternatively you could use renderTemplateToStream() instead of renderTemplateToStorage() and deal with the upload by yourself (using different parameters).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans