Auto populate short Description of Request with short description variable of requested item

Vasilis Anastas
Tera Expert

Hello , I have made a requested item with a var short description. I want when a user writes something in short description and press submit, automatically this short description to populate request's short description. I tried this BR on table requested_itemand works ok, BUT it disappears the requested item. 

 

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

var req = current.request.getRefRecord();
req.short_description = current.short_description;
req.update();

})(current, previous);

 

 

 

VasilisAnastas_0-1668518899397.png

 

 

VasilisAnastas_1-1668518982987.png

 

as you can see, its empty. normally it should have the requested item. But as long as BR is active, it doesn't show it to me. When BR is not active, Requested item appears normaly.

 

thank u!

 

5 REPLIES 5

RaghavSh
Kilo Patron

Try below:

var req = new GlideRecord('sc_request');

req.addQuery('sys_id',current.request);

req.query();

if(req.next())

{

req.short_description = current.variables.short_description;

req.update();

}

This BR should be on RITM table.


Raghav
MVP 2023

it doesn't work for me 

Hi Vasilis,

 

Hi Vasilis,
It worked for me . Please update your scripts with WHEN TO RUN : After  & Insert and Update

(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id',current.request);
gr.query();
while(gr.next()){	
	gr.short_description = current.variables.short_description;
	gs.log('Short:' +current.variables.short_description);
	gs.log('Short1:' +gr.short_description);
	gr.update();
	}
})(current, previous);

 

Screenshot:

MDAQUIBKHAN_0-1668524346320.png

MDAQUIBKHAN_1-1668524431982.png

 

@Vasilis can you share the screenshot of your BR.


Raghav
MVP 2023