In SC Task form UI action button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 02:44 AM
Hi All,
In sc task form have ui action button, The button called create story. When i click on create story then assignment group auto populate in story based on task group.
Task group into story table assignment group. when click on create story button on sc task.
Please help me ui action script.
Regards,
Tharun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 03:13 AM
Hi @Tharun13 ,
you can use below script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2024 03:33 AM
Name: Create Story
Table: sc_task (SC Task)
Action name: create_story
Show on form: Checked
Condition: current.assignment_group != '' (Optional, to ensure the Assignment Group is filled before showing the button)
Client: Unchecked (this will be a server-side action)
And script would be something like below and feel free to add/modify anything in that:
(function executeAction() {
// Create a new Story record
var storyGR = new GlideRecord('rm_story');
storyGR.initialize();
// Set the Assignment Group based on the SC Task's Assignment Group
storyGR.assignment_group = current.assignment_group;
// Copy relevant fields from the SC Task to the Story (optional)
storyGR.short_description = 'Story created from SC Task: ' + current.number;
storyGR.description = current.description;
storyGR.u_requestor = current.opened_by; // Example: setting the requestor field
// Insert the new Story record
var storyID = storyGR.insert();
if (storyID) {
gs.addInfoMessage('Story ' + storyGR.number + ' created successfully.');
action.setRedirectURL(storyGR);
} else {
gs.addErrorMessage('Failed to create Story.');
}
})();
Hope this will help you but pls test this code on lower instance before implementing.