Invalid 'Choice' record even though the selected outside Table 'Case' is allowed?

Ganesh291
Tera Contributor

Hi All,

I'm getting below error when i am trying to insert choice value through the business rule. The BR is in Global scope.

ErrorInvalid 'Choice' record even though the selected outside Table 'Case' is allowed

Script:

var gr2 = new GlideRecord('sys_choice');
gr2.initialize();
gr2.name = 'sn_customerservice_case';
gr2.language = 'en';
gr2.element = 'resolution_code';
gr2.label = 'Value1';
gr2.value = 'value1';
gr2.insert();

-------------------------------------------------------------------------------------

how to resolve this, suggestions please....

 

Thank You.

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what is the business use-case to create choice from script?

it worked fine for me from global scope

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

i Hope you did it through background scripts, can you try using business rules.

 

Use case is that as a agent i want to maintain the drop down values on case form.

I have created a custom table and it can be accessible for Group A.

As on when user insert a record in custom table, i want to create the choice value on case form.

 

Custom table contains same fields which are there on case form.

 

Thank You.

@Ganesh29 

Didn't try that.

Should work from there as well.

Can you try to create choice for incident etc table and check

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

For Incident, Problem, Knowledge etc, it will work for sure through the BR, for case it is not working.

Can you please try to execute same script via BR and see the behavior.

 

By default all the users will be in Global scope after successful login, We are trying to insert the choice value for Case table which is in Customer scope.

We are trying to create choice value for Case table i.e trying to create choice values for cross scope tables.

 

Thank You,

Ganesh.