Coming soon: The SuperOffice Community will get a major update Learn more

Find persons that have not consented to marketing e-mails using FindAgent

Hi

I'm trying to get the selected values using a FindAgent, becauce i have have a large number of persons to check.

Below you can see my code.

personIds contains 3 Ids. One of the persons have selected one of the e-marketing options, while the others have e-marketing off and none og the options selected.

How can i get only the selected options using the FindAgent?

Using the code below the results contains the following two rows, and makes no sense:

        public static List<Tuple<int, string, string, InactiveReason>> FindPeopleWhoHaveNotConsented(List<string> personIds, int eMarketingPermissions)
        {
            var output = new List<Tuple<int, string, string, InactiveReason>>();

            using (var findAgent = new FindAgent())
            {
                var columns = new[] {
                    "shipmenttypereservation.person_id",
                    "shipmenttypereservation.ShipmentType_id"
                };
                var find = new ArchiveRestrictionInfo[]
                {

                    new ArchiveRestrictionInfo()
                    {
                        Name = "shipmenttypereservation.person_id",
                        Operator = "oneOf",
                        Values = personIds.ToArray(),
                    },
                    new ArchiveRestrictionInfo()
                    {
                        Name = "shipmenttypereservation.ShipmentType_id",
                        Operator = "=",
                        Values = new[] { eMarketingPermissions.ToString() },
                        InterOperator = InterRestrictionOperator.And
                    }
                };
                var results = findAgent.FindFromRestrictionsColumns(
                    find,
                    "Dynamic",
                    columns,
                    int.MaxValue,
                    0);

                if (results?.ArchiveRows != null && results.ArchiveRows.Length > 0)
                {

                    foreach (var result in results.ArchiveRows)
                    {
                        var personId = GetValueInt(result.ColumnData["shipmenttypereservation.person_id"]);
                        var shipmentTypeId = GetValueInt(result.ColumnData["shipmenttypereservation.ShipmentType_id"]);
                    }
                }
            }

            return output;
        }

RE: Find persons that have not consented to marketing e-mails using FindAgent

I think this may be harder than it seems.
A quick question:

If you were to use the Find system, Company/contact, with the "Consent - E-Marketing" restriction, Yes/No, would you get the result rows you expected?

If so, provider is "findcontact", restriction name is "hasEmarketingConsent".

/conrad

Von: Conrad Weyns 20. Aug 2020

RE: Find persons that have not consented to marketing e-mails using FindAgent

Hi Conrad

I have some code getting a single person using a PersonAgent.

This method contains the expected result, but it seems to be too slow when i want to check up on a larger amount of persons.

Kind regards

Michael

Von: Michael Jensen 21. Aug 2020

RE: Find persons that have not consented to marketing e-mails using FindAgent

Hi Michael,
Not sure I can be of much help.
Some netserver provider expert should be better off.
I tend to always try the find system first...

All I know is that the consent system has it challenges. I did implement it in Win.
This "negative" storage strategy can be tricky.

If you want to find a person that has E-markeing ON and say "Promotions" checked ON, you have to know that "Promotion" is a valid ShipmentType and that there is no ShipmentTypeReservation record for it.

Observe also that the state of the checkboxes is not lost when turning off e-marketing with the slider button.

The findcontact provider with the restriction I mentioned befre will give you all person that have the sldier button either On or Off.
Perhaps you can then iterate over that result to query the consent system using a PersonAgent.

Also, there is a global setting that affects the interpretation of the old "Has Direct Mailing".
See Admin/Privacy/Consent: checkbox for "Filter recipients based on e-markeing consent and active subscriptions.

Conrad 

Von: Conrad Weyns 21. Aug 2020