Not getting user full name by using getDisplayName() in Business Rule

ServiceNow SA
Kilo Guru

Hi All,

I want to display the user's full name instead of User id in Created by field for sysapproval_approver table only for Knowledge approvals. Hence i am writing below one line in My BR:

<<current.sys_created_by = gs.getUserDisplayName();>>

But while checking in Background script, i am not getting the user's name by using getDisplayName(). It is coming as undefined.

I am using the below script for background check :

var kb = new GlideRecord('sysapproval_approver');

kb.addEncodedQuery('document_id=sys_id^source_table=kb_knowledge');

kb.query();

if(kb.next()){

gs.print(kb.sys_created_by.getDisplayName());

}

Can anybody tell me what is the issue here?

9 REPLIES 9

Hi,



Happy to hear. Please mark the question as answered.



Thanks !


ServiceNow SA
Kilo Guru

I used the same code in BR and its not updating the record..


Hi,



Can you paste the BR code.


It worked after using below code:



current.sys_created_by = gs.getUserDisplayName();




Thanks all for your help.


Hi,



Happy to hear !


Please mark this thread as answered.