In SC Task form UI action button

Tharun13
Tera Contributor

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

2 REPLIES 2

Runjay Patel
Giga Sage

Hi @Tharun13 ,

 

you can use below script.

var incGr = new GlideRecord('story table name');
incGr.initialize(); // initialize the incGr object
incGr.assignment_group = current.assignment_group; // set the field value
incGr.insert();
 
Please accept the solution if it helped.

 

 

 

Abhay Kumar1
Giga Sage

@Tharun13 

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.