-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPag-Ext50100.GlLinePageExt.al
More file actions
72 lines (64 loc) · 2.8 KB
/
Pag-Ext50100.GlLinePageExt.al
File metadata and controls
72 lines (64 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// <summary>
/// PageExtension GlLinePageExt (ID 50100) extends Record General Journal.
/// </summary>
pageextension 50100 GlLinePageExt extends "General Journal"
{
actions
{
addfirst(processing)
{
action(ReadLinesJson)
{
Caption = 'Read lines from Json file';
ApplicationArea = all;
trigger OnAction()
var
JsonBuffer: Record "JSON Buffer" temporary;
PteTempBlob: Record PteTempBlob;
JournalLine: Record "Gen. Journal Line";
filename: text;
Ins: InStream;
OutS: OutStream;
Json: JsonObject;
PteBlobRecordRef: RecordRef;
BlobFieldRef: FieldRef;
JsonText: Text;
TempBlob: Codeunit "Temp Blob";
LineNo: Integer;
begin
PteTempBlob.DeleteAll();
PteBlobRecordRef.Open(database::PteTempBlob);
BlobFieldRef := PteBlobRecordRef.Field(10);
// BlobFieldRef.CreateOutStream(OutS);
if UploadIntoStream('Give me the Json', '', '', filename, Ins) then begin
PteTempBlob.Init();
PteTempBlob.Code := '1';
PteTempBlob.Blob.CreateOutStream(OutS);
CopyStream(OutS, Ins);
PteTempBlob.Insert(true);
PteBlobRecordRef.get(PteTempBlob.RecordId);
BlobFieldRef := PteBlobRecordRef.Field(10);
BlobFieldRef.CalcField();
JsonBuffer.ReadFromBlob(BlobFieldRef);
LineNo := 10000;
if JsonBuffer.FindSet() then
repeat
if JsonBuffer.Path.Contains('DIARIO_ORIGEN')
then begin
JournalLine.Init();
JournalLine."Line No." := LineNo;
LineNo += 10000;
JournalLine.Validate("Journal Template Name", JsonBuffer.Value);
end;
if JsonBuffer.Path.Contains('DIARIO_LOTE') then begin
JournalLine.Validate("Journal Batch Name", JsonBuffer.Value);
JournalLine.Insert(true);
end;
//parse the rest of your json here
until JsonBuffer.Next() = 0;
end;
end;
}
}
}
}