Updating "additional comments" with text when catalog task state changes to "awaiting caller"

cicgordy
Tera Guru

Hi all, 

 

I would like to update "additional comments" field with text when a catalog task (sc_task) state changes to "awaiting caller" state choice, so when I select "awaiting caller" and then save the form, then the additional comments should automatically update with text. 

 

Many thanks in advance.

2 REPLIES 2

Paul Deonarine3
Tera Expert

You can achieve this requirement by creating a business rule on the sc_task table that runs when the task state changes to "awaiting caller".

 

// Get the task record and check if the state has changed to "awaiting caller"
var task = new GlideRecord('sc_task');
if (task.get(current.sys_id) && task.state == 4) { // 4 is the choice value for "awaiting caller"

  // Update the "additional comments" field with your desired text
  task.setValue('additional_comments', 'Your additional comments here');

  // Update the task record
  task.update();
}

 

You can customize the text in the setValue() function to whatever you want the additional comments to be. Make sure to replace current.sys_id with the appropriate field name for the task record's sys_id.

You can create a business rule with the following settings:

  • Table: sc_task
  • When: Before
  • Update: True
  • Insert: False
  • Advanced: true

Then, copy and paste the script above into the script field of the business rule.

Once the business rule is saved, it will automatically update the "additional comments" field with your desired text when the task state changes to "awaiting caller".

Hi,

thanks for helping but sadly this didn't work.

 

The requirements above needs to be achieved only for "hardware request" catalog item and only for this task called "check stock".

I also tried to set conditions for that catalog item and task but still didnt work