Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SCullman committed Jul 5, 2020
0 parents commit 4e6be57
Show file tree
Hide file tree
Showing 8 changed files with 306 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.alpackages
.vscode
*.app
42 changes: 42 additions & 0 deletions Pag50101.ContactRelation.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
page 50101 "Contact Relation"
{
ApplicationArea = All;
Caption = 'Contact Relations';
PageType = List;
SourceTable = "Contact Relation";
UsageCategory = Lists;

layout
{
area(content)
{
repeater(General)
{
field("No."; "No.")
{
ApplicationArea = All;
}
field("Contact No."; "Contact No.")
{
ApplicationArea = All;
}
field("Contact Name"; "Contact Name")
{
ApplicationArea = All;
}
field("Description"; Description)
{
ApplicationArea = All;
}
field("Relation to Contact No."; "Relation to Contact No.")
{
ApplicationArea = All;
}
field("Relation to Contact Name"; "Relation to Contact Name")
{
ApplicationArea = All;
}
}
}
}
}
43 changes: 43 additions & 0 deletions Pag50102.ContactRelationApi.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
page 50102 "Contact Relation Api"
{

APIGroup = 'nav';
APIPublisher = 'publisher';
APIVersion = 'v1.0';
DelayedInsert = true;
EntityName = 'relation';
EntitySetName = 'relations';
ODataKeyFields = "No.";
PageType = API;
SourceTable = "Contact Relation";

layout
{
area(content)
{
repeater(General)
{
field(number; "No.")
{
ApplicationArea = All;
Caption = 'no';
}
field(contactNo; "Contact No.")
{
ApplicationArea = All;
Caption = 'contactNo';
}
field(relationToContactNo; "Relation to Contact No.")
{
ApplicationArea = All;
Caption = 'relationToContactNo';
}
field(description; "Description")
{
ApplicationArea = All;
Caption = 'description';
}
}
}
}
}
60 changes: 60 additions & 0 deletions Pag50103.ContactApi.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
page 50103 "Contact Api"
{

APIGroup = 'nav';
APIPublisher = 'publisher';
APIVersion = 'v1.0';
DelayedInsert = true;
EntityName = 'contact';
EntitySetName = 'contacts';
PageType = API;
SourceTable = Contact;

layout
{
area(content)
{
repeater(General)
{
field(number; "No.")
{
ApplicationArea = All;
Caption = 'number', Locked = true;
}
field(firstName; "First Name")
{
ApplicationArea = All;
Caption = 'firstName', Locked = true;
}
field(surname; Surname)
{
ApplicationArea = All;
Caption = 'surname', Locked = true;
}
field(name; Name)
{
ApplicationArea = All;
Caption = 'name', locked = true;
}
field(id; SystemId)
{
ApplicationArea = All;
Caption = 'id';
}
field(companyNo; "Company No.")
{
ApplicationArea = All;
Caption = 'companyNo';
}

part(relations; 50102)
{
ApplicationArea = All;
EntityName = 'relation';
EntitySetName = 'relations';
}
}
}
}

}
39 changes: 39 additions & 0 deletions Tab50100.ContactRelation.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
table 50100 "Contact Relation"
{
Caption = 'Contact Relation';
DataClassification = CustomerContent;

fields
{
field(1; "No."; Code[10])
{
Caption = 'Entry No';
DataClassification = CustomerContent;
}
field(2; "Contact No."; Code[20])
{
TableRelation = Contact."No.";
}
field(3; "Relation to Contact No."; Code[20])
{
TableRelation = Contact."No.";

}
field(4; "Description"; Text[50])
{
Caption = 'Description';
DataClassification = CustomerContent;
}
field(5; "Contact Name"; Text[50])
{
FieldClass = FlowField;
CalcFormula = lookup (Contact.Name where("No." = field("Contact No.")));
}
field(6; "Relation to Contact Name"; Text[50])
{
FieldClass = FlowField;
CalcFormula = lookup (Contact.Name where("No." = field("Relation to Contact No.")));
}
}
keys { key(PK; "No.") { } }
}
37 changes: 37 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"id": "6d2eaf41-642c-41ff-81ce-c3cc06d9d3c4",
"name": "api navigation",
"publisher": "publisher",
"version": "1.0.0.0",
"brief": "",
"description": "",
"privacyStatement": "",
"EULA": "",
"help": "",
"url": "",
"logo": "",
"dependencies": [
{
"id": "63ca2fa4-4f03-4f2b-a480-172fef340d3f",
"publisher": "Microsoft",
"name": "System Application",
"version": "16.0.0.0"
},
{
"id": "437dbf0e-84ff-417a-965d-ed2bb9650972",
"publisher": "Microsoft",
"name": "Base Application",
"version": "16.0.0.0"
}
],
"screenshots": [],
"platform": "16.0.0.0",
"idRanges": [
{
"from": 50100,
"to": 50149
}
],
"showMyCode": true,
"runtime": "5.0"
}
Binary file added assets/ContactRelationList.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
This is a spike project to explore both the REST Webservices and the new custom API of Business Central. My interest here is especially in the O-Data navigation features. I would like to query whole entity trees with only a single call using $expand. The [documentation](https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/webservices/use-containments-associations) I have found so far on the subject is extremely scarce and also outdated.

### A simple relation beween contacts

For this purpose there is a simple table called `Tab50100.ContactRelation`.

```
table 50100 "Contact Relation"
{
Caption = 'Contact Relation';
DataClassification = CustomerContent;
fields
{
field(1; "No."; Code[10])
{
DataClassification = CustomerContent;
}
field(2; "Contact No."; Code[20])
{
TableRelation = Contact ."No.";
}
field(3; "Relation to Contact No."; Code[20])
{
TableRelation = Contact."No.";
}
field(4; "Description"; Text[50])
{
DataClassification = CustomerContent;
}
/* ...and some flow fields for convienience ... */
}
keys { key(PK; "No."){}}
}
```
For each contact a list of their relationships (e.g. "Child" or "Partner of") to other contacts can now be stored. Therefore the table contains the two fields `Contact No` and `Relation to Contact No.` which handle the table relations to the built in table `Contact` (5050).

### A Page for Editing

For a basic editing UI, I created a page of type list `Page50101.ContactRelation`:

```
page 50101 "Contact Relation"
{
ApplicationArea = All;
Caption = 'Contact Relations';
PageType = List;
SourceTable = "Contact Relation";
UsageCategory = Lists;
layout
{
area(content)
{
repeater(General)
{
field("No."; "No.")
{
ApplicationArea = All;
}
field("Contact No."; "Contact No.")
{
ApplicationArea = All;
}
field("Description"; Description)
{
ApplicationArea = All;
}
field("Relation to Contact No."; "Relation to Contact No.")
{
ApplicationArea = All;
}
}
}
}
}
```
This allows me to enter a few relations:
![Image of a few contact relations]("assets/ContactRelationList.jpg")


###

0 comments on commit 4e6be57

Please sign in to comment.