Get/Set information about E-marketing on person card

lock
push_pin
done
Answered
2

If im not mistaken, its standard to have E-marketing on the person card for mailings.

I'm wondering how you can get/set these values from CRMScript. Been trying to read around the person table, NSPerson, NSPersonAgent and NSPersonEntity classes, but not finding any useful information on it.

30 Sep 2025 | 02:40 PM

All Replies (2)

Hi Fredric,

From a brief look into this topic I can give you some pointers at least.

The setting for the header "E-marketing" vs the underlying interests seems stored separately in the database.

The header "E-marketing" is part of the GDPR-consent workflow. This kind of data is stored in the ConsentPerson-table and can be handled using the class NSConsentPerson (https://docs.superoffice.com/en/automation/crmscript/reference/CRMScript.NetServer.NSConsentPerson.html). This class seems to be used in the consent functions in the NSPersonAgent-class. Right now I cannot see exactly which Agent that could be used for this.

The underlying "E-Marketing"-interests seems to be stored in the table "ShipmentTypeReservation" where the actual list of types is stored in the table "ShipmentType". This could be set using a SearchEngine-query, but it is probably better to use some kind of NSAgent or NS-Class if available. But right out of the box I cannot see which Agent that may be used for this. But hopefully some other person here may be able to give some complementary directions. But have a another look at the different NSClasses below, now when you know that it might be connected to Consent or ShipmentTypeReservations.

Do note that the table "ShipmentTypeReservation" will only contain a record for the interests under "E-Marketing" that are NOT checked, meaning it is like a block-list. No record automatically means allow. THOUGH, the the state in this table on person level is only relevant as long as the "E-marketing"-consent is also set to allowed. So this table can still contain a state for a person if the "E-marketing" consent is revoked. So blocks are made in at least two levels, first E-Marketing-consent-level, secondary on E-marketing-interest-level. I can see in the Person-table that there is two related fields, "nomailing" and "blockEmarketing". "nomailing" seems to mirror the enable/disable-value of the "E-Marketing"-header, "blockEmarketing" might be some kind of explicit block that may be set in some workflow.

According to the DB-Docs for the person-table:

"nomailing"
Do not send DM's to this person

"blockEmarketing"
Do not send E-marketing materials to this person

A general tip
A general tip when trying to understand the SuperOffice API is to also get a grip of the underlying tables and structure of the database, as this often can give you a better understanding of how data is stored and where. You also have Star-schemas for each table, which could give some indication of what other related tables that might be interesting when trying to understand a certain area of the product or a certain workflow. Often there are corresponding NS-classes for the different tables, which could help you understand what next table or class to investigate. :)

Some relevant tables for this topic:
--
https://docs.superoffice.com/en/database/tables/consentperson.html
https://docs.superoffice.com/en/database/tables/shipmenttypereservation.html
--
https://docs.superoffice.com/en/database/tables/person.html
https://docs.superoffice.com/en/database/tables/legalbase.html
https://docs.superoffice.com/en/database/tables/consentpurpose.html
https://docs.superoffice.com/en/database/tables/consentsource.html
https://docs.superoffice.com/en/database/tables/shipmenttype.html

Some NS-classes that might be worth investigating:
https://docs.superoffice.com/en/automation/crmscript/reference/CRMScript.NetServer.NSMarketingAgent.html
https://docs.superoffice.com/en/automation/crmscript/reference/CRMScript.NetServer.NSShipmentMessageBlockEntity.html

Best Regards
Marcus

2 Oct 2025 | 09:50 AM

Both consent info and shipment types can be set using the personentity with the personagent;

 

#setLanguageLevel 4;

Integer personId = 1754;

NSPersonAgent personAgent;

NSPersonEntity personEntity = personAgent.GetPersonEntity(personId);

NSConsentInfo[] personConsents = personEntity.GetConsents();

foreach (NSConsentInfo personConsent in personConsents)
{
    Bool isEmarketing = personConsent.GetConsentPurposeKey().equalsIgnoreCase("EMARKETING");

    // do things
}

NSSelectableMDOListItem[] shipmentTypes = personEntity.GetShipmentTypes();

// do things

personEntity.SetShipmentTypes(shipmentTypes);

personEntity = personAgent.SavePersonEntity(personEntity);
2 Oct 2025 | 09:57 AM

Add reply