The CreatorCon Call for Content is officially open! Get started here.

setPreference in a scoped application

Jack Littlewort
Giga Guru

Hi,

 

What is the correct way to use the setPreference function to set a user preference in a scoped application?

1 ACCEPTED SOLUTION

Jack Littlewort
Giga Guru

I have found the solution to this, you have to use savePreference when in a scoped app.

 

https://docs.servicenow.com/bundle/orlando-application-development/page/app-store/dev_portal/API_ref...

View solution in original post

4 REPLIES 4

Pratiksha Kalam
Kilo Sage

Hello,

You can create script include and call that from scoped application.

Have look on this,

http://www.john-james-andersen.com/blog/service-now/servicenow-user-preferences-server-client-access...

If answer is helpful please mark correct or helpful!

Thanks,

Pratiksha

I have tried this method and it doesn't seem to work.

 

I am attempted this in a virtual agent script, I'm not sure if that has any affect on setting user preference.

Willem
Giga Sage
Giga Sage

You can try this:

grUserPreference = new GlideRecord('sys_user_preference');
grUserPreference.addQuery('name',< your user preference >);
grUserPreference.query();
if( grUserPreference.next() ) {
       grUserPreference.value = <your value>;
       grUserPreference.update();
}

Jack Littlewort
Giga Guru

I have found the solution to this, you have to use savePreference when in a scoped app.

 

https://docs.servicenow.com/bundle/orlando-application-development/page/app-store/dev_portal/API_ref...