How to Update the short description and Description on the catalog item

AjKadam
Tera Contributor

Hi All,

I have a requirement Where I want to update the 'short description' of the catalog item to the 'Name of the catalog item' If short description is empty

What is the best way to achieve it

 

Thanks

1 ACCEPTED SOLUTION

Hi,

BR will work only for new records

If you want to fix older catalog items with empty short description then you need to run schedule job.

1) check which catalog items are having empty short description

2) then set short description with catalog item name

Sample script below for job

1) test this for 5 records using setLimit(5);

once verified then remove this line setLimit(5);

updateRecords();

function updateRecords(){

var rec = new GlideRecord('sc_cat_item');

rec.addEncodedQuery('short_descriptionISEMPTY');

rec.setLimit(5); // use for testing then remove this line

rec.query();

while(rec.next()){

rec.short_description = rec.name;

rec.update():

}

}

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

30 REPLIES 30

Harshal Gawali
Giga Guru

Hi Aj,

can you elaborate your requirement in detail?

 

Regards,

Harshal.

Tony Chatfield1
Kilo Patron
Hi, I would suggest a before insert/update br with trigger condition of short description is empty. current.short_description = current.yourReferenceField;

I don't want to perform any operation

How many items are there in [sc_cat_item], which don't have short description just I want to pass the particular 'catalog item Name' in the short description

Dhananjay Pawar
Kilo Sage

Hi AJ,

Try below BR,

find_real_file.png

find_real_file.png

And paste below code in script section.

 

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

current.short_description = current.cat_item.getDisplayValue();

})(current, previous);

 

Thanks,

Dhananjay.