Setting Exported filename

Hi,

This has worked in View page → Page_Exporting event:

 global $ExportFileName;
 $ExportFileName = 'Rekvisition_LILLEØRE_L' . $this->id->CurrentValue;

but does not work in v2024.

Any suggestions?

tia
/Poul

If you used to set the global variable $ExportFileName to change the file name of the exported file, you need to update your code and set the $doc->FileName property in Page_Exporting server event.

For more info, please read Export API.

Thanks. Works great.

But if I want to add an ID from the current record, $this->id->CurrentValue does not work???

You cannot get the CurrentValue of a Field in that Page_Exporting server event.

The solution for your case is, you should get the CurrentValue by using Page_Render server event of View Page, and save it into a session variable:

// save to myID session
Session("myID", $this->id->CurrentValue);

after that, simply get that session variable value in Page_Exporting server event:

// get from myID session
$myID = Session("myID");

Alternatively, you may try $this->id->OldValue in Page_Exporting.

Thanks mobhar and arbei,

I went with arbei’s solution that worked for me.

/Poul