How to update ctask once created

Km Sh
Tera Contributor

Hi

How to update description of Change request - CTASKs after it created.
For ex: I have couple of CTASKs got created & need to update the description based on short_description.

 

tes1.png

Appreciate your inputs. Thanks

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@Km Sh You can create an onBefore Update business rule on your Change Task table with Advanced checkbox checked.

 

You can use the following script in the script field.

 

if (current.short_description.changes()) {
    // Update the description with the new short description value
    current.description = 'Updated Short Description: ' + current.short_description;
}

Hope this helps.

@Sandeep Rajput 

actually I need to update all the CTASK descriptions, if it matches to short description i.e.; MACD Devices:

for ex: Ctask1, Ctask2, Ctask3...

 var text1 = "MACD Devices: xyz hello";
 var str = current.getValue('short_description');
    if (str.indexOf("text1") > -1) {
        current.setValue('description', text);
       }

Is this correct or missing something..

@Km Sh You can try to use the following script in a business rule if you wish to update the description of all change tasks associated with the change request.

 

var changeTaskGR = new GlideRecord('change_task');
        changeTaskGR.addQuery('change_request', current.change_request); // Match the parent Change Request
        changeTaskGR.query();
        // Loop through each Change Task and update the description
        while (changeTaskGR.next()) {
        var text1 = "MACD Devices: xyz hello";
        var str = changeTaskGR.getValue('short_description');
    if (str.indexOf(text1) > -1) {
            changeTaskGR.description ='Updated description';//Add updated description here
            changeTaskGR.update();
            gs.info('Updated Change Task: ' + changeTaskGR.number);
        }
}
Please mark my response helpful and accepted solution if it addresses your question.

mister_mentor
Kilo Guru

Karimullah,

 

"Out of the box" it's possible to update the description on both normal change requests and change tasks at any stage. If you are referring to a Normal type change request where you are unable to modify the description then you will have to reference your companies own customizations.

 

If this is a Standard type change then out of the box the description field on change request (and short description on change tasks) are disallowed from editing. The assumption is that it's a standardized change so those fields (and more) should always be the same. You can adjust which fields are mandatory, read only, and more in the 'Standard Change Properties' module.