- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 10:44 AM
Hi All,
We have a custom field on the knowledge form called "Content Owner Group", If "Ownership Group" is from one of the specific groups( around 100 groups), I need to populate the Content Owner Group as "XYZ" group.
I cannot use UI policy, Got some idea from community Client Script + Display BR to achieve this.
I have created new system property and defined all the Ownership Group sys ids, But I am not sure how to fetch Sys property values in client script to achieve the requirement.
Can anyone help me on this or is there any other way to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 11:12 AM - edited 11-02-2022 11:36 AM
Hello,
Please do the below:-
Write a display BR with below code:-
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.my_property = gs.getProperty('propertyname');
})(current, previous);
The on the onchange client script of Ownership Group field call it using the below code:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var myProperty = g_scratchpad.my_property;
if(myProperty.indexof(newValue)>-1)
{
g_form.setValue('Content Owner Groupfieldname','sysidofxyzgroup');
}
}
Please mark my answer as correct based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2022 11:12 AM - edited 11-02-2022 11:36 AM
Hello,
Please do the below:-
Write a display BR with below code:-
(function executeRule(current, previous /*null when async*/) {
g_scratchpad.my_property = gs.getProperty('propertyname');
})(current, previous);
The on the onchange client script of Ownership Group field call it using the below code:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var myProperty = g_scratchpad.my_property;
if(myProperty.indexof(newValue)>-1)
{
g_form.setValue('Content Owner Groupfieldname','sysidofxyzgroup');
}
}
Please mark my answer as correct based on Impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 02:58 AM - edited 11-03-2022 03:49 AM
Hi @Saurav11,
I have tried as you have mentioned, I am getting on Change script error as below, Please see below attachments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 04:04 AM
Hello,
Sorry It would be indexOf(capital O)
so the code will be as below:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var myProperty = g_scratchpad.my_property;
if(myProperty.indexOf(newValue)>-1)
{
g_form.setValue('Content Owner Groupfieldname','sysidofxyzgroup');
}
}
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2022 04:20 AM - edited 11-04-2022 04:23 AM
Hi @Saurav11,
It is working now, I have one more case, if "Content owner group" is populated based on "Ownership group", then users should not be able to modify the "Content owner group" field. In the on change client script I made "Content owner group" as read only, But after saving the form, the field will be editable. Users are able to modify that field, it should not happen. how to achieve this?