How SO-Sentry in Table Userpreference work to set User-Rights for SO Fields in SO Online

Hi,

 

I try to implement entry for SO Sentry in table Userpreference to set restriction for some SO fields for certein User group in SO Online.

NSPreferenceAgent myUPAgent;
NSPreference myUP = myUPAgent.CreateDefaultPreference();
NSPreferenceSpec mySpec;
mySpec.SetSection("Rights-sale");
mySpec.SetKey("Sale.earning_percent");
myUP.SetSpecification(mySpec);
myUP.SetLevel(4);    // set level to 4 for restriction for User group
myUP.SetDisplayType(0);
myUP.SetDisplayTooltip("Some User cannot read this field!");
myUPAgent.SavePreference(myUP);
Integer upID = myUP.GetUserPreferenceId();

But the id of Entry "upID" is still 0 after it's saved, and If I retrive the table, the deflevel is still 5 for single user, the prefvalue is still null, only prefsection and prefkey are correctly saved.

Then I try to update the entry via SerachEngine, like:

SearchEngine se;
se.addData("UserPreference.deflevel", "4");    // set level to 4 for restriction for User group
se.addData("UserPreference.owner_id", "9");    // user group id = 9
se.addData("UserPreference.prefvalue", "0,Some User cannot read this field");
se.addCriteria("UserPreference.userpreference_id", "OperatorEquals", "778", "OperatorAnd", 0);
se.update();

Now I got the entry 778 I want in th table userpreference, but after re-Login of the user from User Group 9, he can still read and edit this field "Sale.earning_percent".

does the sentry-Entries in table Userpreference really work for SO Online? Thanks!

RE: How SO-Sentry in Table Userpreference work to set User-Rights for SO Fields in SO Online

Hi,

 

Is there anyone who can provide feedback, whether the entry to define Userright in SO Fields in table Userpreference really works for SO Online?

 

Thanks!

Af: Jianchun You 29. okt 2020

RE: How SO-Sentry in Table Userpreference work to set User-Rights for SO Fields in SO Online

Hi Jianchun,

Yes, it does work in online. See Marc's example in this post using SearchEngine.

Be advised, once set, it will take about 10 minutes for the preference to take affect.

Best regards.

Af: Tony Yates 29. okt 2020

RE: How SO-Sentry in Table Userpreference work to set User-Rights for SO Fields in SO Online

Tony: I'm just curious. What's the technical reason for the 10 minute delay and what are the advantages of that reason instead of applying the effect directly?

/Marcus

Af: Marcus Svenningsson 29. okt 2020