NoMailing changes made by a Before Save Person trigger are not reflected in the UI after save

lock
push_pin
done
Besvart
2

 

Expected:
Changing NoMailing through a Before Save Person trigger should update both the stored data and the UI immediately after saving.

Actual:
Changing NoMailing through a Before Save Person trigger updates the value in the database/backend, but the UI continues to display the previous value until the record is reloaded.

P.S.: I also tried updating the consent information from the same
Before Save Person trigger.

Updating LegalBaseId, LegalBaseKey and LegalBaseName to the
withdrawn values did not change the observed behaviour either.

SuperOffice_noMailing_Recording.zip 
Steps to reproduce:

  1. Create a Before Save Person trigger.
  2. In the trigger, set the following script. maybe change your sTestPersonId:
#setLanguageLevel 4;

String sTestPersonId = "212";

EventData ed = getEventData();

String sPersonId = ed.getInputValue("ActivePersonId");

if (sPersonId != sTestPersonId)
    return;

String sFirstName = ed.getInputValue("PersonEntity.Firstname");
String sLastName = ed.getInputValue("PersonEntity.Lastname");
String sNoMailing = ed.getInputValue("PersonEntity.NoMailing");

// 1. Works with Lastname.
// UI reflects the modified value immediately after Save.
if (!sLastName.endsWith(" Test"))
{
    ed.setOutputValue("PersonEntity.Lastname", sLastName + " Test");
}

// 2. works not with nomailing
// searchagent does reflect the new value aftrer the Person Save
// but the UI does not.
// thus, if someone changes the Entity again in the UI, this gets toggeld again,
// and it becomes a mess really fast
if (sNoMailing == "false")
{
    ed.setOutputValue("PersonEntity.NoMailing", "true");
}
else if (sNoMailing == "true")
{
    ed.setOutputValue("PersonEntity.NoMailing", "false");
}

// But perhaps you'll find another way.

11. nov. 2026 | 02:42 p.m.

Alle Svar (2)

Not sure what you use case is here, but NoMailing is an legacy/obsolete field from before consent management was introduced. If you want to change the persons's consent setting you can use the SetConsent function of the PersonAgent in a after save trigger event.

Example;

NSPersonAgent personAgent;

personAgent.SetConsent(personId, "EMARKETING", "USER", "61F", "");
11. nov. 2026 | 02:59 p.m.

Hi David, thank you for your reply.

I am not sure excactly, but i think the agent.setconsent will be overwritten through the person save itself.
We are in the Before Save Event after all.
One can modify the eventData, which we do and the consent becomes Withdrawn for example, 
but one has to refresh the UI manually. If someone change the email, saves and changes another field,
the UI Updates the noMailing back, which triggers the Consent to be changed as well.



The use case is that some customers have multiple persons with the same e-mail, and if one of those persons
changes the e-mail (one and only) we are supposed to withdraw the consent and disable the E-marketing Person-Interest.

There are other possibilities (like the privacy confermation email) to change that also.



We do indeed not only try to set the NoMailing field, but also are modyfiing the Consent for the on person change event, something like this for Withdrawing our own Consent.
ed.setOutputValue("PersonEntity.Consents[" + idx.toString() + "].LegalBaseKey", "WITHDRAW");

this works, kindof, because the person has the correct data when refreshing. but the UI data is stale, which is a issue.

35 m siden | 01:56 p.m.

Legg til svar