Create Scrum Task - Analysis Task - Business Rule with Script not working

Philip Owen
Tera Contributor

Why is this script with a Business Rule not working? 

 

Scenario is that I want to create Tasks from when a story is created to prevent them manually being created. 

 

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

    var gr = new GlideRecord('sn_safe_scrum_task');
    gr.Initialize();
    gr.type = '1';
    gr.short_description = "Analysis Task";
    gr.parent = current.sys_id;
    gr.insert();

})(current, previous);
 
the ge.type Discionary Entry is correct being = 1
This is to be 'inserted' 'After' so why is the task not appearing? I have the correct table as well. 
7 REPLIES 7

Brad Bowman
Kilo Patron
Kilo Patron

If you are not seeing the resultant scrum_task record, first add a gs.info log line to the beginning of the function to confirm the BR is triggering and the script is actually running.  Once you have confirmed this, check the system log when this is attempted to see if there are any errors trying to insert the record.  Otherwise, there could be another Business Rule or Data Policy that is preventing the insert without an error if a mandatory field is not populated.  You could try a similar script with a hard-coded parent sys_id in a Fix Script to take the BR trigger and scope out of the equation.  Do you have any Filter Conditions or Condition on the script tab?  Is the Business Rule in the same scope as the table it's running on?

Philip Owen
Tera Contributor

 Thanks Brad,

 

No there are no conditions, from what I have been learning and I am fairly new to scripting but am understanding it the more I do so the way I am reading my code it should present me with an Analysis Task once I have created a Story. 

 

I am going to add a loop that will add the additional tasks but wanted to the see the tangible result in my own instance before adding that loop, which I am not seeing yet. 

Philip Owen
Tera Contributor

I've fixed the issue using a SCUM view but how to you get the tasks appearing in Default View what most people will be using? 

 

Also, this is the loop that I am using which does not seem to be working any view. Any suggestions anyone? 

 

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    for (i = 1; i < 5; i++) {
        var type = i.toString();
        var gr = new GlideRecord('sn_safe_scrum_task');
        gr.initialize();
        gr.type = type;
        gr.short_description = "Scrum Task " + Type;
        gr.parent = current.sys_id;
        gr.insert();
    }
})(current, previous);


   

So you are saying the task is being created, but you just didn't have the related list added? 

 

From the hamburger menu, click Configure -> Related Lists. Make sure the view shows "Default" and add your related list wherever you want it to appear. Click Save to save your changes.