FileExtension: String;
The FileExtension property returns extension of the file attached to the task execution result.
Executing the example requires that the repository contains a scheduled tasks container with the OBJ30776 identifier and a task of regular report calculation.
Sub Main;
Var
MB: IMetabase;
Cont: IScheduledTasksContainer;
Tasks: IMetabaseObjectDescriptors;
Task: IScheduledTask;
Result: IScheduledTaskResult;
Begin
MB := MetabaseClass.Active;
Cont := MB.ItemById("OBJ30776").Bind As IScheduledTasksContainer;
Tasks := Cont.Tasks;
Task := Tasks.Item(0).Edit As IScheduledTask;
Result := Task.ExecuteImmediate(True);
If Result.HasDataStream Then
Result.ReadDataStream(new FileStream.Create("c:\" + (Task As IMetabaseObject).Name + "." + Result.FileExtension, FileOpenMode.Create, FileShare.Exclusive) As IIOStreamSys);
End If;
End Sub Main;
After executing the example task execution is performed and then the received result is saved locally.
See also: