Print

eDoreczenia_SearchBAE

The eDoreczenia_SearchBAE() function searches the database of electronic addresses (BAE) on behalf of the selected mailbox by passing specified search criteria. This function returns a list of found entities (subjects, i.e. citizens, companies, state and educational institutions, NGOs and etc.) with basic information about them (i.e. eDelivery address, correspondence postal address, (sur)name, company name, NIP, KRS, PESEL and etc.).

Syntax

eDoreczenia_SearchBAE(mailboxId, searchOptions);

Function arguments

  • mailboxId – (String) an identifier of the mailbox on behalf of which the query will be sent. The mailbox has to be registered in AMODIT with unique id.
  • searchOptions – (Object) a set of criteria which allows to distinguish the list of entities to return.

Return value

This eDoreczenia_SearchBAE() function returns Object.
This complex object contains following properties:

  • Success – returns True, if the operation succeds;
  • CombinedErrorMessage – returns description of an error in case of the operation failure;
  • SearchStatus – returns a status of operation.

Object structure of the returned data from response contains more elements and they are shown below in the section of examples.

Examples

Example 1

An example shows how to define different variants of searching criteria and execute the eDoreczenia_SearchBAE() function. Moreover, there is also an example on how to handle response depending on status and lines of code that present fetching data from a found item.

if ([searchType] == 'CitizenByNameSurnameAndPESEL')
{
  searchOptions.searchCategory = 'INDIVIDUAL';
  searchOptions.name = [Name];
  searchOptions.surname = [Surname];
  searchOptions.pesel = [PESEL];
}
if ([searchType] == 'CitizenByNameSurnameAndUEId')
{
  searchOptions.searchCategory = 'INDIVIDUAL';
  searchOptions.name = [Name];
  searchOptions.surname = [Surname];
  searchOptions.ue = [UE];
}
if ([searchType] == 'PublicTrustProfessionByNameAndSurname')
{
  searchOptions.searchCategory = [publicTrustProfession];
  searchOptions.name = [Name];
  searchOptions.surname = [Surname];
  searchOptions.pesel = [PESEL];
  // filter is optional, cannot be used together with 'ue'
  // searchOptions.ue = [UE]; // filter is optional
}
if ([searchType] == 'CompanyOrganizationPublicInstitutionByNIP')
{
  searchOptions.searchCategory = 'ORGANISATION,PUBLIC_INSTITUTION,COMPANY';
  searchOptions.nip = [NIP];
}
if ([searchType] == 'CompanyOrganizationPublicInstitutionByKRS')
{
  searchOptions.searchCategory = 'ORGANISATION,PUBLIC_INSTITUTION,COMPANY';
  searchOptions.krs = [KRS];
}
if ([searchType] == 'CompanyOrganizationPublicInstitutionByRegon')
{
  searchOptions.searchCategory = 'ORGANISATION,PUBLIC_INSTITUTION,COMPANY';
  searchOptions.regon = [Regon];
}
if ([searchType] == 'CompanyOrganizationPublicInstitutionByPostalAddress')
{
  searchOptions.searchCategory = 'ORGANISATION,PUBLIC_INSTITUTION,COMPANY';
  searchOptions.entityName = [entityName];
  // params below are mandatory
  headquartersAddress.countryCode = [countryCode];
  headquartersAddress.city = [city];
  headquartersAddress.buildingNumber = [buildingNumber];
  // params below are optional
  headquartersAddress.postalCode = [postalCode];
  headquartersAddress.street = [street];
  //headquartersAddress.flatNumber = [flatNumber];
  searchOptions.headquartersAddress = headquartersAddress;
}
if ([searchType] == 'CompanyOrganizationPublicInstitutionByEDA')
{
  searchOptions.searchCategory = 'ORGANISATION,PUBLIC_INSTITUTION,COMPANY';
  searchOptions.recipientEdas = [EDA];
}
res = eDoreczenia_SearchBAE([mailboxId], searchOptions);
if (!res.Success)
{
  if (res.SearchStatus == 'NotFound')
  {
    ShowMessage(1,'No item can be found. Description: ' + res.CombinedErrorMessage);
  }
  if (res.SearchStatus == 'Error')
  {
    ShowMessage(1,'Error occured. ErrorDescription: ' + res.CombinedErrorMessage);
  }
}
else
{
  if (res.SearchStatus == 'Ok')
  {
    ShowMessage(1,'Single item has been found');
    if (res.Result != '')
    {
      total = res.Result.total;
      firstItem = res.Result.FirstItem;
      if (firstItem != '')
    {
      if (firstItem.CurrentEntry != '')
     {
        currentEntry = firstItem.CurrentEntry;
        [Item_EntityName] = currentEntry.entityName;
        [Item_Name] = currentEntry.name;
        [Item_Surname] = currentEntry.surname;
        [Item_LegalForm] = currentEntry.legalForm;
        [Item_IsPublic] = currentEntry.isPublic;
        [Item_DesignedOperator] = currentEntry.designatedOperator;
        [Item_Pesel] = currentEntry.pesel;
        [Item_NipStatus] = currentEntry.nipStatusText;
        [Item_Nip] = currentEntry.nip;
        [Item_Krs] = currentEntry.krs;
        [Item_Regon] = currentEntry.regon;
        [Item_Ue] = currentEntry.ue;
        [Item_KppId] = currentEntry.kppId;
        if (currentEntry.correspondenceAddress != '')
        {
          correspondenceAddress = currentEntry.correspondenceAddress;
          [correspondenceAddress_country] = correspondenceAddress.countryCodeText;
          [correspondenceAddress_postalCode] = correspondenceAddress.postalCode;
          [correspondenceAddress_city] = correspondenceAddress.city;
          [correspondenceAddress_street] = correspondenceAddress.street;
          [correspondenceAddress_buildingNumber] = correspondenceAddress.buildingNumber;
          [correspondenceAddress_flatNumber] = correspondenceAddress.flatNumber;
          [correspondenceAddress_postalOffice] = correspondenceAddress.postalOffice;
          [correspondenceAddress_postOfficeBox] = correspondenceAddress.postOfficeBox;
          [correspondenceAddress_streetType] = correspondenceAddress.typeOfStreetText;
          [correspondenceAddress_voivodeship] = correspondenceAddress.voivodeship;
          [correspondenceAddress_district] = correspondenceAddress.district;
          [correspondenceAddress_community] = correspondenceAddress.community;
        }
        if (currentEntry.headquartersAddress != '')
        {
          headquarterAddress = currentEntry.headquartersAddress;
          [headquarterAddress_country] = headquarterAddress.countryCodeText;
          [headquarterAddress_postalCode] = headquarterAddress.postalCode;
          [headquarterAddress_city] = headquarterAddress.city;
          [headquarterAddress_street] = headquarterAddress.street;
          [headquarterAddress_buildingNumber] = headquarterAddress.buildingNumber;
          [headquarterAddress_flatNumber] = headquarterAddress.flatNumber;
          [headquarterAddress_postalOffice] = headquarterAddress.postalOffice;
          [headquarterAddress_postOfficeBox] = headquarterAddress.postOfficeBox;
          [headquarterAddress_streetType] = headquarterAddress.typeOfStreetText;
          [headquarterAddress_voivodeship] = headquarterAddress.voivodeship;
          [headquarterAddress_district] = headquarterAddress.district;
          [headquarterAddress_community] = headquarterAddress.community;
        }
      }
      if (firstItem.MainEDA != '')
      {
        mainEda = firstItem.MainEDA;
        [Item_MainEDA] = mainEda.recipientEda;
      }
      if (firstItem.SecondaryEDAs != '')
      {
        foreachobject(firstItem.SecondaryEDAs)
        {
           // this.recipientEda; // get EDAs of secondary mailboxes and save them somewhere
        }
      }
    }
  }
}
if (res.SearchStatus == 'MoreItems')
{
  ShowMessage(1,'More than one item have been found. Try to apply more strict criteria to find single item.');
  if (res.Result != '' && res.Result.Items != '')
  {
    foreachobject(res.Result.Items)
    {
      // handle each item separatly just like in case of only one item (when SearchStatus is 'Ok')
      // this.CurrentEntry;
    }
  }
}
}

 

Czy artykuł był pomocny?
0 na 5 gwiazdek
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
How Can We Improve This Article?