Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

extract first name and last name from the given text to glide from sys_user table

Kevin68
Tera Expert

Hi 

 

extract first name and last name from the given text to glide from sys_user table

the text I got is (last_name,first_name) Zach, Maria.

how can I extract these two and glide from sys_user table based on both first name and last name?

can I use this query 

var gr = new GlideRecord('sys_user');
gr.addEncodedQuery("first_name=row[header12].substring(',')^last_name=row[header12].substring(0,',')");

?

1 ACCEPTED SOLUTION

Harshal Aditya
Mega Sage

Hi Kevin,

Please try below script 

 

var name = "Tuter, Abel";
var first_name = name.split(",")[1].trim();
var last_name = name.split(",")[0].trim();
gs.log(first_name);
gs.log(last_name);

var gr_user = new GlideRecord("sys_user");
gr_user.addEncodedQuery("first_name="+first_name+"^last_name="+last_name);
gr_user.query();
if(gr_user.next()){
gs.log(gr_user.name);
}

 

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

 

Regards,

Harshal

View solution in original post

1 REPLY 1

Harshal Aditya
Mega Sage

Hi Kevin,

Please try below script 

 

var name = "Tuter, Abel";
var first_name = name.split(",")[1].trim();
var last_name = name.split(",")[0].trim();
gs.log(first_name);
gs.log(last_name);

var gr_user = new GlideRecord("sys_user");
gr_user.addEncodedQuery("first_name="+first_name+"^last_name="+last_name);
gr_user.query();
if(gr_user.next()){
gs.log(gr_user.name);
}

 

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

 

Regards,

Harshal