Need help with building logic to populate User name of the form based on Employee Number sentvia API

Hritik
Tera Expert

Hi Community,

need your help to build a logic for my requirement below.

 

Please see my requirement:

 

I have a catalog form which has fields Employee Number and User name. 

I need to create request via REST API call from third party app. The rest call will send the Employee Number of the user and I need to auto populate the User name of the form when employee number is sent via rest call.

 

I can achieve this via Script Include and Client script, but it does  not work for REST call after req is created.

 

Please note: On User table, there's a field called Employee Number for user profile which is unique.

 

Kindly suggest me a way-out here.

 

 

Thanks in Advance,

Hritik.

2 REPLIES 2

Hritik
Tera Expert

Can this be achieved via After BR ?

I am not sure about the code. Pls help.

@Hritik :

Yes . It can be achieved by BR. (after insert). Assuming it request table. BR will on sc_req_item table.  

1. when to run- select condition specific item name 

2. Check advanced checkbox. in script section. First get employee number  from REST call response then below line of code

var emp_no= employee number from REST call

if (!gs.nil(emp_no)){

var grUser= new GlideRecord("sys_user");

if(grUser.get("employee_number_field", emp_no)){

current. variables. employee_name = grUser. employee _name_field

current.update()

}

}

Please use your field/variable names accordingly.

Hope it helps. Kindly mark helpful/accepted if it helps you in any way.

Regards,

Priyanka Salunke