London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

External system integration - mappings disappear

Vote:
0

I've tried out the External system integration and got it to work but whenever the site is restarted/rebuilt the mappings disappear which makes the functionality useless. Any pointers on where to look or is this just a bug?

#188816
Mar 05, 2018 8:10
Vote:
0

When mapping is saved, it is stored into a property of the FormContainerBlock. So it should be there when you do restart/rebuild. Do you have custom the editor for that mapping? Or do you return consitent data from your ExternalFieldMappingService?

#188817
Mar 05, 2018 8:25
Vote:
0

The following is the class used for the mapping/autofill:

public class CustomerDataAutofill : IExternalSystem, IAutofillProvider
    {
      
        public string Id => "CustomerDataAutofill";

        public IEnumerable<IDatasource> Datasources
        {
            get
            {
                var datasource = new Datasource()
                {
                    Id = "ContextCustomerInfo",
                    Name = "Kontextbaserad kunddata",
                    OwnerSystem = this,
                    Columns = new Dictionary<string, string>
                    {
                        {"FirstName", "Förnamn"},
                        {"LastName", "Efternamn"},
                        {"EMail", "E-post"},
                        {"Phone", "Telefonnummer"},
                        {"Address", "Adress"},
                        {"PostalCode", "Postnummer"},
                        {"City", "Ort"},
                    }
                };

                return new[] { datasource };
            }
        }

        public IEnumerable<string> GetSuggestedValues(IDatasource selectedDatasource, IEnumerable<RemoteFieldInfo> remoteFieldInfos, ElementBlockBase content,
            IFormContainerBlock formContainerBlock, HttpContextBase context)
        {
            if (selectedDatasource == null || remoteFieldInfos == null)
            {
                return Enumerable.Empty<string>();
            }

            if (!this.Datasources.Any(ds => ds.Id == selectedDatasource.Id))  // datasource belong to this system
            {
                return Enumerable.Empty<string>();
            }


            var activeRemoteFieldInfo = remoteFieldInfos.FirstOrDefault(mi => mi.DatasourceId == selectedDatasource.Id);

            if (activeRemoteFieldInfo == null) return Enumerable.Empty<string>();


            var currentUser = ServiceLocator.Current.GetInstance<ICurrentUser>();
            var restService = ServiceLocator.Current.GetInstance<IRestService>();

            switch (activeRemoteFieldInfo.ColumnId)
            {
                case "FirstName":
                    return new List<string> {
                        currentUser.FirstName
                    };

                case "LastName":
                    return new List<string> {
                        currentUser.LastName
                    };
                case "EMail":
                    return new List<string> {
                        currentUser.Email
                    };
                case "Phone":
                    var phonenumber = restService.GetContactById(currentUser.ContactId).Telefonnummer1;
                    if (string.IsNullOrWhiteSpace(phonenumber))
                        phonenumber = restService.GetContactById(currentUser.ContactId).Telefonnummer2;

                    return new List<string>
                    {
                       phonenumber
                    };
                case "Address":
                    return new List<string>
                    {
                        restService.GetContactById(currentUser.ContactId).Folkbokforingsadress.StreetAddress
                    };
                case "PostalCode":
                    return new List<string>
                    {
                        restService.GetContactById(currentUser.ContactId).Folkbokforingsadress.ZipCode
                    };
                case "City":
                    return new List<string>
                    {
                        restService.GetContactById(currentUser.ContactId).Folkbokforingsadress.City
                    };
                default: 
                    return Enumerable.Empty<string>();
            }
        }
    }
#188865
Mar 06, 2018 9:47
Vote:
0

I have tried your class with Forms and the mappings are still there when I rebuild/restart the site. Are you running custom code to clear/create new database?

#188871
Mar 06, 2018 10:10
Vote:
0

Reason for the failures is unknown. We believe a faulty synchronization between servers could have been a reason but we are not really sure. It is working now anyway. :)

#189928
Mar 27, 2018 14:49
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.