UI Action - How to control multiple field value in the system properties.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 08:33 AM - edited 11-13-2024 08:37 AM
Hi All,
In the sctask we have a UI Action for story creation. when we click that UI Action story will get created .
where I have a use case
1.if the assignment group is network then in the story following fields need to get updated
assignment group as "Network Admin", then CI - Network and product is Network
2. if the assignment group is wintel then story following fields need to get updated
assignment group as" Wintel Admin", then CI- Wintel and product is Wintel.
Instead of hard coding of sys id in the UI Action . I was trying via " System Properties".
where in the system property Value
I have given value as
[
{
"assignment_group": "Network",
"product": "Network",
"cmdb_ci": "Network"
},
{
"assignment_group": "wintel",
"product": "wintel,
"cmdb_ci": " wintel"
}
]
In the UI Action:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 10:09 AM
Two quick things to check. In the first line, are you using 'propertyname' generically so not to put the real name? If not, then you need to change that to the name of your property. Secondly, I'd check the values in your property for assignment_group and make sure those values actually match the display value from your record's assignment group, since they will be case sensitive as you are not converting the value to lowercase.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 10:54 AM
Hi @Alpha_K ,
The code you have written is of type Object and work with variables defined as objects.
But, in the system properties, you do not have type as Object. I believe you have selected as String.
Which should not be the case.
So, you should convert this String into Object in the code and the code should be written in only one line as the indention does not work when converting into Object.
[{"assignment_group": "Network", "product": "Network","cmdb_ci": "Network"},{"assignment_group": "wintel","product": "wintel","cmdb_ci": "wintel"}]
var arr1 = gs.getProperty('Community.Property');
// Parse the string into an actual JavaScript array
var arr = JSON.parse(arr1);
for(var i=0;i<arr.length;i++)
{
if(arr[i].assignment_group == "Network")
{
gs.info(arr[i].product);
}
}
*** Script: Network
Another option is to create Individual Properties.
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 11:31 AM - edited 11-13-2024 11:33 AM
Hello @Alpha_K
There are few mistakes:
- Make sure the values set in property and the display value follows the same case. Here 'Network' and 'wintel' are in different case therefore cross check it once again with the display value.
- Since the property is set as a string, parsing the string becomes mandatory.
- syntax: current.setValue('field_name' , value); field_name is missing.
- The 'Theme' is not set in the property. If not needed then remove it from the code as well.
The updated script:
var arr1 = gs.getProperty('propertyname');
var arr = JSON.parse(arr1);
var grp = current.getDisplayValue('assignment_group');
for (var i = 0; i < arr.length; i++) {
if (arr[i].assignment_group.toLowerCase() == grp.toLowerCase()) {
current.setValue('product', arr[i].product); //set the field name Product
current.setValue('theme', arr[i].theme); //set the field name Theme
current.setValue('cmdb_ci', arr[i].cmdb_ci); //set the field name CI
current.update();
}
}
I hope this solution helps you resolve the issue.
"If you found my answer helpful, please give it a like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar