- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 09:51 AM
Hi Community,
In a "Change Request" form I have field called "Release Type", and it's a drop down field with two options in it i.e. "Red" and "Blue".
There is a requirement where, Change Request must be created automatically as soon as deployment of any app is completed and "Release Type" field should be auto populated with option "BLACK", but this "BLACK" option should not visible to anyone when they are creating "Change Request" manually.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 10:25 AM
Hi @prakhar_yadav,
To meet the requirement of automatically creating a Change Request with the "Release Type" field auto-populated with the option "BLACK" in ServiceNow, while ensuring that this option is not visible when creating a Change Request manually, you can follow these steps:
Create the "BLACK" Option:
- Go to System Definition > Choice Lists.
- Add "BLACK" as a choice for the "Release Type" field in the "Change Request" table.
Hide "BLACK" Option in Manual Creation:
- Create a Client Script for the "Change Request" table.
- Use this script to remove "BLACK" from the dropdown for users creating requests manually:
function onLoad() {
g_form.removeOption('release_type', 'BLACK');
}
Automate Change Request Creation After Deployment:
- Create a Business Rule that triggers after deployment.
- Use this script to create a new Change Request with "Release Type" set to "BLACK":
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('change_request');
gr.initialize();
gr.short_description = 'Auto-created Change Request';
gr.release_type = 'BLACK';
gr.insert();
})(current, previous);
This setup ensures "BLACK" is available for automatic use but hidden during manual creation.
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 10:25 AM
Hi @prakhar_yadav,
To meet the requirement of automatically creating a Change Request with the "Release Type" field auto-populated with the option "BLACK" in ServiceNow, while ensuring that this option is not visible when creating a Change Request manually, you can follow these steps:
Create the "BLACK" Option:
- Go to System Definition > Choice Lists.
- Add "BLACK" as a choice for the "Release Type" field in the "Change Request" table.
Hide "BLACK" Option in Manual Creation:
- Create a Client Script for the "Change Request" table.
- Use this script to remove "BLACK" from the dropdown for users creating requests manually:
function onLoad() {
g_form.removeOption('release_type', 'BLACK');
}
Automate Change Request Creation After Deployment:
- Create a Business Rule that triggers after deployment.
- Use this script to create a new Change Request with "Release Type" set to "BLACK":
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('change_request');
gr.initialize();
gr.short_description = 'Auto-created Change Request';
gr.release_type = 'BLACK';
gr.insert();
})(current, previous);
This setup ensures "BLACK" is available for automatic use but hidden during manual creation.
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2024 11:47 AM
Hey @Yashsvi
Thank you for your prompt and detailed response. It is working but the only problem is, When "BLACK" is auto populated, it should be visible after creation of Change Request automatically.
But in this case, in the list view of "Change Request" form it's clearly visible that "BLACK" is populated, but as soon as I will open that form it's not visible, the field is populated with none.
My point is after creation of Change Request automatically, "BLACK" should be visible as auto populated