- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 03:31 AM
Hello,
I have created an UI action to create a story from the enhancement. I have written a below code, but it is not working properly to create a story.
var story = new GlideRecord('rm_story');
story.state = '1'; //State - ready
story.short_description = current.short_description;
story.description = current.description;
story.assignment_group = current.assignment_group;
story.assigned_to = current.assigned_to;
story.enhancement = current.number;
story.opened_by = current.opened_by;
gs.info('New story is created ' + story.number');
gs.addInfoMessage('New story is created ' + story.number);
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:16 AM
Hi @Swati251
This is OOTB available
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:21 AM
Hello @Swati251,
You can correct your code with the below code:
var story = new GlideRecord('rm_story');
story.initialize();
story.state = '1'; //State - ready
story.short_description = current.short_description;
story.description = current.description;
story.assignment_group = current.assignment_group;
story.assigned_to = current.assigned_to;
story.enhancement = current.number;
story.opened_by = current.opened_by;
story.insert();
gs.addInfoMessage('New story is created ' + story.number);
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 05:18 PM
Hello @Swati251 ,
It may your 'Enhancement' field will be reference field, so that's why that field is not being populated with the Enhancement number which is String. So please use the below code to to populate the Enhancement field on the story with the current number of the Enhancement. And to stay on your Enhancement record after clicking on the UI Action.
var story = new GlideRecord('rm_story');
story.initialize();
story.state = '1'; //State - ready
story.short_description = current.short_description;
story.description = current.description;
story.assignment_group = current.assignment_group;
story.assigned_to = current.assigned_to;
story.enhancement.setDisplayValue(current.number);
story.opened_by = current.opened_by;
story.insert();
//action.setRedirectURL(story); // Use to redirect to the created Story record
action.setRedirectURL(current);
gs.addInfoMessage('New story is created ' + story.number);
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 05:20 PM
Hello @Swati251
It may your 'Enhancement' field will be reference field, so that's why that field is not being populated with the Enhancement number which is String. So please use the below code to to populate the Enhancement field on the story with the current number of the Enhancement. And to stay on your Enhancement record after clicking on the UI Action.
var story = new GlideRecord('rm_story');
story.initialize();
story.state = '1'; //State - ready
story.short_description = current.short_description;
story.description = current.description;
story.assignment_group = current.assignment_group;
story.assigned_to = current.assigned_to;
story.enhancement.setDisplayValue(current.number);
story.opened_by = current.opened_by;
story.insert();
//action.setRedirectURL(story); // Use to redirect to the created Story record
action.setRedirectURL(current);
gs.addInfoMessage('New story is created ' + story.number);
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:13 AM
Hi @Swati251,
you need to add story.insert() to actually insert/create the record.
Best regards,
Rene
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:16 AM
Hi @Swati251
This is OOTB available
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:21 AM
Hello @Swati251,
You can correct your code with the below code:
var story = new GlideRecord('rm_story');
story.initialize();
story.state = '1'; //State - ready
story.short_description = current.short_description;
story.description = current.description;
story.assignment_group = current.assignment_group;
story.assigned_to = current.assigned_to;
story.enhancement = current.number;
story.opened_by = current.opened_by;
story.insert();
gs.addInfoMessage('New story is created ' + story.number);
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.