Hello to all.
I created my API page of Contacts, but want to add Alternative Addresses for every contact.
I created also Alternative Addresses list part page. And call as expand in postman, but get this error:
Could not find a property named 'contAltAddresses' on type 'NAV.contactIntApi'My API contact Page:
page 71357586 /Contacts Api_VSl_VSL/
{
ApplicationArea = all;
UsageCategory = None;
SourceTable = Contact;
PageType = API;
EntitySetName = 'contacts';
EntityName = 'contact';
ODataKeyFields = /No./;
Extensible = true;
APIPublisher = 'vsl';
APIGroup = 'vsl';
DelayedInsert = true;
Caption = 'Contacts Int. API', Locked = true;
APIVersion = 'v1.0';
//InsertAllowed = true;
layout
{
area(Content)
{
repeater(Repeater)
{
field(no; Rec./No./)
{
ApplicationArea = all;
ToolTip = 'No';
}
field(name; Rec.Name)
{
ApplicationArea = all;
ToolTip = 'Name';
}
field(taxidvsl; Rec./TAX ID_VSL/)
{
ApplicationArea = all;
ToolTip = 'TAX ID';
}
field(vATregistrationno; Rec./VAT Registration No./)
{
ApplicationArea = all;
ToolTip = 'VAT Registration No.';
}
field(privacyblocked; Rec./Privacy Blocked/)
{
ApplicationArea = all;
ToolTip = 'Privacy Blocked';
}
field(address; Rec.Address)
{
ApplicationArea = all;
ToolTip = 'Address';
}
field(city; Rec.City)
{
ApplicationArea = all;
ToolTip = 'City';
}
field(cityId; CityId)
{
ApplicationArea = All;
ToolTip = 'City Id';
}
field(county; Rec.County)
{
ApplicationArea = All;
ToolTip = 'County';
}
field(countryRegCodeID; countryRegCodeID)
{
ApplicationArea = All;
ToolTip = 'Country Region Code ID';
}
part(contAltAddresses; ContactAltAddress_VSL)
{
ApplicationArea = All;
// ToolTip = 'Contact Alternative Addresses';
Caption = 'Contact Alt Address', Locked = true;
EntityName = 'contAltAddress';
EntitySetName = 'contAltAddresses';
SubPageLink = /Contact No./ = field(/No./);
}
field(modifiedAt; Rec.SystemModifiedAt)
{
ApplicationArea = All;
ToolTip = 'Modified At';
}
// field(shipToAddrss1; GetAlternativeAddreses(Rec))
// {
// ApplicationArea = All;
// }
}
}
}
var
ContactAltAddress: Record /Contact Alt. Address/;
PostCode: Record /Post Code/;
CountryRegion: Record /Country/Region/;
CityId: Integer;
countryRegCodeID: Integer;
// procedure GetAlternativeAddreses(Contact: Record Contact) TextExt: Text
// var
// JsonVar: Text;
// begin
// ContactAltAddress.SetRange(/Contact No./, Contact./No./);
// JsonVar := '[';
// if ContactAltAddress.FindSet() then
// repeat
// JsonVar += '{/code/:/' + ContactAltAddress.Code + '/,';
// JsonVar += '/companyName/:/' + ContactAltAddress./Company Name/ + '/,';
// JsonVar += '/address/:/' + ContactAltAddress./Address/ + '/,';
// JsonVar += '/city/:/' + ContactAltAddress.City + '/';
// JsonVar += '/postCode/:/' + ContactAltAddress./Post Code/ + '/';
// JsonVar += '},';
// until ContactAltAddress.Next() = 0;
// if JsonVar.Contains('code') then
// JsonVar := CopyStr(JsonVar, 1, StrLen(JsonVar) - 1);
// JsonVar += ']';
// TextExt := JsonVar;
// end;
trigger OnAfterGetRecord()
begin
if PostCode.Get(Rec./Post Code/, Rec.City) then
CityId := PostCode./City ID WIND_VSL/;
if CountryRegion.Get(Rec./Country/Region Code/) then
countryRegCodeID := CountryRegion./CountryRegCodeID WIND_VSL/;
end;
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
Rec.Insert(true);
Rec.Modify(true);
exit(false);
end;
trigger OnDeleteRecord(): Boolean
begin
Rec.Delete(true);
end;
}
And my List Part Page:
page 71357599 /ContactAltAddress_VSL/
{
PageType = ListPart;
Editable = false;
LinksAllowed = false;
DelayedInsert = true;
Caption = 'contactAltAddresses';
ODataKeyFields = /Contact No./;
SourceTable = /Contact Alt. Address/;
AutoSplitKey = true;
Permissions = tabledata /Contact Alt. Address/ = rimd;
layout
{
area(Content)
{
repeater(rep)
{
ShowCaption = false;
field(/code/; Rec.Code)
{
ApplicationArea = All;
ToolTip = 'Specifies the code for the alternate address.';
}
field(companyName; Rec./Company Name/)
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the name of the company for the alternate address.';
}
field(companyName2; Rec./Company Name 2/)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies the additional part of the company name for the alternate address.';
Visible = false;
}
field(address; Rec.Address)
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the alternate address of the contact.';
}
field(address2; Rec./Address 2/)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies additional address information.';
Visible = false;
}
field(city; Rec.City)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies the city of the contact''s alternate address.';
Visible = false;
}
field(postCode; Rec./Post Code/)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies the postal code.';
Visible = false;
}
field(county; Rec.County)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies the county for the contact''s alternate address.';
Visible = false;
}
field(countryRegionCode; Rec./Country/Region Code/)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies the country/region of the address.';
Visible = false;
}
field(phoneNo; Rec./Phone No./)
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies the telephone number for the alternate address.';
}
field(faxNo; Rec./Fax No./)
{
ApplicationArea = RelationshipMgmt;
ToolTip = 'Specifies the fax number for the alternate address.';
Visible = false;
}
field(eMail; Rec./E-Mail/)
{
ApplicationArea = RelationshipMgmt;
ExtendedDatatype = EMail;
ToolTip = 'Specifies the e-mail address for the contact at the alternate address.';
Visible = false;
}
}
}
}
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
Rec.Insert(true);
exit(false);
end;
trigger OnDeleteRecord(): Boolean
begin
Rec.Delete(true);
end;
}
I called in postman: https://address/
contactIntApi?$expand=contAltAddresses.
Error: {
/error/: {
/code/: /BadRequest/,
/message/: /Could not find a property named 'contactAltAddresses' on type 'NAV.contactIntApi'. CorrelationId: 1f82cc58-6690-43ec-b9d5-232b0820a0e8./
}
}
Do you know how to solve this problem?