How to safely allow users control over choices

thomaskennedy
Tera Guru

We have an app where we get frequent requests for updates to sys_choice rows. I'd like to give the users a way to do these updates themselves, without a major refactor, without a mass data update, and without having them touch sys_choice or know anything about it. So I thought to set up a table to act as a front end for sys_choice, and use business rules to push whatever updates are made to that proxy table into sys_choice, making sure that I'm operating only on rows belonging to this table in this app. (There will be other business rules, not shown here, to ensure this.)

My table is called x_99999_kwtest1_communication. This is the table the choices belong to. Here's what I've tried:

  1. I created a table 'x_99999_kwtest1_storecommkwproxy', modeled after sys_choice. This is the proxy table the user do inserts on.
  2. Updated sys_choice and sys_choice_set to allow inserts and updates from other applications.
  3. Created a business rule to run after Insert:

(function executeRule(current, previous /*null when async*/) {

var sc = new GlideRecord("sys_choice");

sc.initialize();

sc.setValue("name", "x_99999_kwtest1_communication"); /* hard coded */

sc.setValue("element", current.getValue("element"));

sc.setValue("hint", current.getValue("hint"));

sc.setValue("label", current.getValue("label"));

sc.setValue("value", current.getValue("value"));

sc.setValue("dependent_value", current.getValue("dependent_value"));

sc.setValue("inactive", current.getValue("inactive"));

sc.setValue("language", current.getValue("language"));

sc.insert();

})(current, previous);

The idea here is that users who have permission to do inserts etc on my proxy table can thereby do inserts on sys_choice.

But when I run this I get:

Invalid 'Table' selected on the Choice record. The 'Communication' table is in application 'KWTest1', but the current application is 'Global'. The 'Table' field can only select 'KWTest1' tables with read and alter access enabled.

It sounds like this business rule will only do inserts etc on tables in the same scoped application the user is in. Is there any way to get this technique to work?

10 REPLIES 10

Hello Thomas,



As I mentioned in my earlier notes, application access setting prevents the creation of choice records from another scope. Please be aware this change will not be captured as part of scope app and customers using the app has to do the change manually.



P.S: This will also be rejected in case the app is intended to be submitted for certification.


Pradeep,



Can you clarify where this setting is? I modified both sys_choice and sys_choice_set to allow it (my Step 2) but I still get this error.


Actually, the error is related to the table option. Scope app prevents the global table from being selected. I don't think we can overwrite this change.


Let me know if that answered your question. If so, please mark it as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.


How To Mark Answers Correct From Community Inbox


Varun,



I allowed create and update on sys_choice and sys_choice_set (see my Step 2 in OP). Still doesn't work!