
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 04:36 AM
Hi,
I created a client script that is setting company field of an incident same as caller.company.
The problem is that I want to set company filed of an incident readOnly after that, and that's not working.
I searched for conflicting UI policies and scripts, but found none. And then I found a business rule that's doing the same but after saving or updating, deactivated it, but problem is still occurring. What else can I do? Maybe I overlooked sth? Please help.
my client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var ga = new GlideAjax('UserCompany');
ga.addParam('sysparm_name', 'getUserCompany');
ga.addParam('sysparm_user_id', newValue);
ga.getXMLAnswer(function(answer){
alert("answer: " + answer);
g_form.setValue('company', answer);
g_form.setReadOnly('company', true);
});
}
my script include
var UserCompany = Class.create();
UserCompany.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getUserCompany: function() {
var userRecord = new GlideRecord('sys_user');
var user_id = this.getParameter('sysparm_user_id');
userRecord.get(user_id);
var companyId = userRecord.company.sys_id.getDisplayValue();
return companyId;
},
type: 'UserCompany'
});
business rule I found
I also share what other scripts I found for incident table, maybe someone will notice sth.
I looked for it here:
client scripts:
ui policies:
data policies:
business rules:
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 06:48 AM
ok, just write below UI Policy and check.
UI policy Action with Company field with Readonly = true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 04:42 AM
if you dont mark it yo readonly, does it set the value?
Thanks
Harshad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 04:54 AM
yes, it does.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 05:20 AM
As mentioned by
You have to make it non-mandatory.
Thanks
Harshad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 06:02 AM