Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Consent tables retrieval. CustomSearch or Provider ??

Hi,

Using NetServer Core, what is best practice for retrieving data from above mentioned tables ? I have tried the CustomSearch approach, but I keep getting Dictionary errors.

Should I use e.g. ConsentPurposeProvider  instead ?

I know a thing or 2 about the provider so here is some info:

The consentpurpose provider is a bit of a wierdo...

It will provide one row per existing consentpurpose and merge these with consentperson rows given some restrictions, typically like "personId=47".

It has 1 optional entity for deleted. Inactive items will be pushed.
So, given a binding to the current person you may get something like this:

Restrictions:
    active=True&name=personId&operator=equals&numvalues=1&value=47

Desired entities: consentPurpose deletedConsentPurpose

I.o.w. person with id 47 has consent for STORE and EMARKETING.

/conrad

Af: Conrad Weyns 12. apr 2018

Hi Morten,

I'm most concerned with the Dictionary Errors you are observing. This obviously should not be happening. Seems most likely you have a corrupt database from failed upgrade or something like that.

What SuperOffice version was the database upgraded to, and what version are the core assemblies you are using? There was this known problem with a change in the Consent-related data, so perhaps you are caught in-between this somehow? Old database, new assemblies, or vice-versa?

Known Issue:

https://community.superoffice.com/en/developer/forum/rooms/topic/netserver-api-group/core-components/netserver-82-breaks-authenticate-method-for-previous-versions/?page=all#RE:-NetServer-8.2-breaks-Authenticate-method-for-previous-versions52988

Best regards.

Af: Tony Yates 13. apr 2018

Hi Tony,

The database is a clean / new SO8.2R4 database.

I'm using the latest SuperOffice.NetServer.Core NuGet packages, which is v8.2.6642.1034

Here is the code I'm rying to execute:

var search = new ConsentPurposeRows.CustomSearch();

search.Restriction = search.TableInfo.Deleted.Equal(S.Parameter(0));
search.OrderBy.Add(search.TableInfo.Name);

var rows = search.ToConsentPurposeRows();

This throws an exception and stacktrace that looks like this:

Message: The given key was not present in the dictionary.
Source: mscorlib

Stacktrace:

   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at SuperOffice.CRM.Data.ConsentPurposeTableInfo.get_Definition() in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Data\ConsentPurpose.cs:line 122
   at SuperOffice.CRM.Security.SentryQueryUpdater.ModifySelect(Select select) in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Security\SentryQueryUpdater.cs:line 198
   at SuperOffice.CRM.Security.SentryQueryUpdater.BeforeGenerate(SqlCommand orgCommand, SqlCommand command) in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Security\SentryQueryUpdater.cs:line 68
   at SuperOffice.Data.QueryProcessor.BeforeGenerate() in C:\agent2\_work\37\s\Server\Source\SoDataBase\Data\QueryProcessor.cs:line 122
   at SuperOffice.Data.SoCommand.GenerateSingleSql() in C:\agent2\_work\37\s\Server\Source\SoDataBase\Data\SoCommand.cs:line 717
   at SuperOffice.Data.SoCommand.ExecuteReader(Nullable`1 behaviour, Int32 pageSize, Int32 pageWanted) in C:\agent2\_work\37\s\Server\Source\SoDataBase\Data\SoCommand.cs:line 486
   at SuperOffice.CRM.Rows.TableRowsBase.RowsLoad(ITableRowLoadHandlerFactory tableRowHandlerFactory) in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Rows\TableRowsBase.cs:line 131
   at SuperOffice.CRM.Rows.PrivateFactory.PrivateConsentPurposeRowsFactory.SuperOffice.Factory.IPrivateFactory.Create(Type type, Type[] constructorArgumentTypes, Object[] constructorArguments) in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Rows\gen\ConsentPurpose.cs:line 2522
   at SuperOffice.Factory.TypeFactories.Create(Type type, Type[] constructorArgumentTypes, Object[] constructorArguments) in C:\agent2\_work\37\s\Server\Source\SoCore\Factory\TypeFactories.cs:line 155
   at SuperOffice.Factory.ClassFactory.Create(Type type, Type[] constructorArgumentTypes, Object[] constructorArguments) in C:\agent2\_work\37\s\Server\Source\SoCore\Factory\ClassFactory.cs:line 343
   at SuperOffice.CRM.Rows.ConsentPurposeRow.ConsentPurposeRowIdxBase.ToConsentPurposeRows(ITableRowLoadHandlerFactory tableRowHandlerFactory) in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Rows\gen\ConsentPurpose.cs:line 2067
   at SuperOffice.CRM.Rows.ConsentPurposeRow.ConsentPurposeRowIdxBase.ToConsentPurposeRows() in C:\agent2\_work\37\s\Server\Source\SoDataBase\CRM\Rows\gen\ConsentPurpose.cs:line 2055
   at Adwiza.DataSync.TransStringToConsentPurpose.TransGUI.InitializeGUI(SyncConfigField pSyncConfigField, SyncConfigTranslator pSyncConfigTranslator) in E:\VS 2017 Solutions\DataSync\82\Adwiza\AdwizaWork\AdwizaWork\DataSync.Net\Translators\TransStringToConsent\TransGUI.cs:line 56

 

Af: Morten Kristensen 13. apr 2018

Hi Morten,

I have tried and am not able to reproduce this error.

Are you sure you are not pointing to a different database than you think? The error would indicate that you do not have the ConsentPurpose table, at least not defined in the DatabaseModel.

You could verify it is in the databasemodel using LinqPad, for example:

Connection.Open();
var dbMgmt = DatabaseManagement.CreateInstance("crm7", this.Connection);
var dbModel = dbMgmt.ReadDatabaseModel();

var consentPurpose = dbModel.Tables.Where(t => t.Name == "ConsentPurpose").First();
consentPurpose.Dump();

Best regards.

Af: Tony Yates 13. apr 2018

Hi Tony,

Mystery solved. The ODBC connection we used had a name that indicated that it pointed to an SO 8.2, but was in fact pointing to an SO 8.1. :-/

Sorry for all the fuss

It works perfectly now

Morten

Af: Morten Kristensen 13. apr 2018