Field on TASK, make it default

Jen11
Tera Expert

Hello,

 

I have the following requirement:

I have a catalog item, on the catalog item if the following box is NOT true: 

Jen11_0-1728323846670.png

Once the form is submitted, on TASK I have a Quantity field, so if the above box is NOT true, I would like the Quantity field on the TASK to default to 1.  

 

How can I achieve that? 

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

If you are referring to a Catalog Task, where quantity is a field as opposed to a Catalog Item variable, on the sc_task table you can create a before Insert Business Rule so that when the Catalog Task is created it will set the quantity field to 1 if the Catalog Item variable box is unchecked.  If this box could be checked after the initial request / after a Catalog Task has been created, then also check the Update box on the When to run tab of the Business Rule, and ensure that the Catalog Item variable has been included in the Catalog Task.

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

    if(current.request_item.variables.variable_name == 'false') {
        current.quantity = 1;
    }
})(current, previous);

View solution in original post

4 REPLIES 4

Brad Bowman
Kilo Patron
Kilo Patron

If you are referring to a Catalog Task, where quantity is a field as opposed to a Catalog Item variable, on the sc_task table you can create a before Insert Business Rule so that when the Catalog Task is created it will set the quantity field to 1 if the Catalog Item variable box is unchecked.  If this box could be checked after the initial request / after a Catalog Task has been created, then also check the Update box on the When to run tab of the Business Rule, and ensure that the Catalog Item variable has been included in the Catalog Task.

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

    if(current.request_item.variables.variable_name == 'false') {
        current.quantity = 1;
    }
})(current, previous);

If it is on CTASK Level, Then I would go with same approach brad suggested and add additional conditions to make sure the BR triggers only for that particular catalog item


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

thank you.  this worked!

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Jen11 

You want to update the quantity on RITM record after the request is submitted?


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP