The CreatorCon Call for Content is officially open! Get started here.

getDisplayValue return nothing

Nico12
Mega Sage

Hi,

 

I have a Business Rule on sysapproval_approver.

 

Im trying to return in the logs the display value of the "sysapproval" field, but it return nothing.

var approvers = [];
	var getApprovers = new GlideRecord('sysapproval_approver');
	getApprovers.addQuery('sysapproval', current.sysapproval);
	getApprovers.addQuery('state','requested'); //only show pending approvals
	getApprovers.query();
	while(getApprovers.next()){
		approvers.push(getApprovers.approver.toString());
		var taskValue = getApprovers.getDisplayValue('sysapproval');
		gs.log('DOC ID : ' + taskValue, "NJA");
	}

	if(taskValue.indexOf('REQ') > -1){
		var getRitm = new GlideRecord('sc_req_item');
		getRitm.addQuery('request',current.sysapproval);
		getRitm.query();
		while(getRitm.next()){
			getRitm.u_approvers = '';
			getRitm.u_approvers = approvers.toString();
			getRitm.update();
		}
	}

 

Logs :

Capture.PNG

 

Regards,

5 REPLIES 5

Pedro Grilo1
Mega Sage

Hi!

 

I believe there may be two (maybe more) reasons for this:

- The display column is not set on the tasks you are searching for

- The approval has been created for a task than no longer exists

 

Can you log as well the sysapproval field value and check if it matches any of the above?

Hi Pedro, 

 

The sysapproval field value return the sys_id of the REQ that im looking for.

For my condition, i need the display value of the REQ (ex: REQXXXX).

 

the "approval for" (sysapproval) column :

 Capture d’écran 2022-11-02 à 20.17.43.png

Bert_c1
Kilo Patron

Hi, according to the documentation:

 

https://developer.servicenow.com/dev.do#!/reference/api/tokyo/server_legacy/c_GlideRecordAPI#r_Glide... 

 

there is no argument to be passed in to the method.

Hi Bert_c1,

 

Well when it's a RITM thats is created from a single item everything is ok, the display value works fine. But when it's a REQ (From Order guide) it return nothing

Capture d’écran 2022-11-02 à 22.05.58.png      Capture d’écran 2022-11-02 à 22.08.36.png