Question

Assigning value to Cached system setting throws console error from base class.

Hi,



We are using a 'cached' system setting variable 'UsrRole' and the value for the variable is set in 'MainHeaderSchema' js page.



//Below is the code used to set the value for the system setting.

Terrasoft.SysSettings.postPersonalSysSettingsValue("UsrRole", "Psychic");



The above throws a console error from the Creatio base file.



polyfills-es5.js?hash=1c11246d9e364108ae4b3e7a42cf435d:1 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')

    at i.fire (all-combined.js:6)

    at i.continueFireEvent (all-combined.js:6)

    at i.fireEventArgs (all-combined.js:6)

    at i.fireEvent (all-combined.js:6)

    at i._translateDecodedMessage (all-combined.js:41)

    at i._channelMsgHandler (all-combined.js:41)

    at i.providerChannelMsgEventHandler (all-combined.js:41)

    at i.fire (all-combined.js:6)

    at i.continueFireEvent (all-combined.js:6)

    at i.fireEventArgs (all-combined.js:6)





Is there any other setting that has to be done ?



Pls suggest.

Like 0

Like

4 comments

Hi,

 

In 7.18.4 everything is set properly for the system setting using the scenario you've shared:

 

1) Create a system setting with the UsrRole code and make it cached. Allow reading it for internal users:

2) Add the following code to the replaced "MainHeaderSchema":

 

define("MainHeaderSchema", [], function() {
	return {
		attributes: {},
		methods: {
			init: function() {
				this.callParent(arguments);
				Terrasoft.SysSettings.postPersonalSysSettingsValue("UsrRole","456");
			}
		}
	};
});

3) Flush Redis and relogin to the app.

 

As a result the value for the setting is set properly:

So this is something else that returns an error on your side or there is a specific set of rights for this setting in your app.

 

Best regards,

Oscar

Hello Anitha,

1) Does the System Setting "UsrRole" have a data type of text?

2) You mention this is a cached setting, is it also a per-user setting? If it is not, try switching to use Terrasoft.SysSettings.postSysSettingsValues() instead.

3) Based on the error, it could be that postPersonalSysSettingsValue is attempting to execute the callback, which hasn't been supplied in the code you provided (the callback should be optional, but maybe it's not properly checking?). Try changing the code to this:

Terrasoft.SysSettings.postPersonalSysSettingsValue("UsrRole", "Psychic", null);
 
// or try something with an actual callback, like this:
 
Terrasoft.SysSettings.postPersonalSysSettingsValue("UsrRole", "Psychic", function(result) {
    if (!result.success) {
        throw new Terrasoft.InvalidOperationException(result.errorInfo.message);
    }
});

Ryan

Ryan Farley,

Thank you for the response Ryan.



1. Yes. the data type is Text

2. It is a per-user setting.



Tried including a callback as mentioned above, but still the same error is thrown.



Pls suggest.

 

Hello Anitha,

I tested and it does work for me for a per-user setting with or without the callback. Can you verify if your system setting is restricted for read or modify in any way?

If I restrict the system setting, and the current user doesn't have access to it, I do get an error similar to yours.

Ryan

 

Show all comments