Function autoSysFields is not allowed in scoped application?

matthallbomgar
Kilo Explorer

Using SNOW Fuji. I've got a scoped application with a private script include. From my script include, I've got the following code:

var journalField = new GlideRecord('sys_journal_field');

journalField.initialize();

journalField.name = 'x_atrm_atroam_session';

journalField.element = 'body';

journalField.element_id = session.sys_id;

journalField.value = chatMessage;

journalField.insert();

This is giving the following error: "Create operation against 'sys_journal_field' from scope 'x_atrm_atroam' has been refused due to the table's cross-scope access policy"

Prior to Fuji and scoped applications, this was possible. What is the proper way to add a journal field as of the Fuji release?

6 REPLIES 6

john_roberts
Mega Guru

Ugh!


This just killed (or severely crippled) one of my apps I had queued up for migration.


Hi Matt,



In scoped app you cannot insert a record into any other scoped table (global scoped) via scripting, unless if you have configure that table to insert/update/delete records from other scoped App. For more details please see the following screenshot.


Screen Shot 2015-03-03 at 8.53.51 AM.png



& you can see the entry of modification also got capture in a scoped app.


Screen Shot 2015-03-03 at 8.55.50 AM.png



After doing above changes, i was able to insert a data into sys_journal_field.



Thanks,


Prashant


Prashant Parbhane I think the issue originally mentioned was GlideRecord.autoSysFields() is not allowed in scope.


This is occasionally used when you need to update the value of records and you do not want the system to generate the typical values for sys_updated, sys_updated_by, sys_created, sys_created_on.


I frequently use this feature when creating demo data that must have distributed created on or updated on values.


Are there any other options to override these fields?


This issue will prevent me from publishing the Data Generator application in the MarketPlace today.


Hi John,



There were two issues asked in the original question on this post. Subject line & the content were for two different issues, the answer which i gave is trying to address the issue reported in the content of the question. Now coming to issue reported to subject part, it looks like its an expected behavior in fuji. For more details please see the link (Scoped GlideRecord API Reference - ServiceNow Wiki).



Thanks,


Prashant