vaInputs.user.first_name to accommodate more than one name

Luiz Lucena
Mega Sage

Hello everyone, 

We are using Virtual Agent and our Service Desk is outsourced, they use their Twilio in their environment (not integrated to our ServiceNow.
So, when someone in our Virtual Agent asks for live agent support, we decided to pass all necessary information through a URL, so within the VA, this is the script passing the data to their Twillio:

(function execute() {
    var spanishLink = 'https://webchat.servicedeskURL.com/?tenant=iss_companyID_gen_es_rc&firstName=' + vaInputs.user.first_name + '&lastName=' + vaInputs.user.last_name + '&email=' + vaInputs.user.email + '&login=' + vaInputs.user.email + '&client=iss_companyID_gen_es_rc&chatId=chat&languageCode=es&countryCode=es';
    return spanishLink;
})()

(I removed the confidential information from URL above)

This is working fine when a user has ONE first and ONE last name, like:
vaInputs.user.first_name: John
vaInputs.user.last_name: Doe

However, when they have compound names (either first or last), Virtual Agent shows BAD OUTPUT LINK.
Like, vaInputs.user.last_name = Double Doe.

find_real_file.png

I could not find anything in the logs, but noticed that after several troubleshoots.
I'll try to convince the company to standardize first and last name to contain only one name, but in the meantime, is there a way to pass more than one name in this variable: vaInputs.user.first_name?

Thanks in advance

1 ACCEPTED SOLUTION

Ah oke clear what you mean with double name 🙂 I guess it could be that a name has multiple spaces?

You could replace the spaces. Have you tried that? Replacing the space with %20.

Something like:

vaInputs.user.first_name.replaceAll(' ', '%20')

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Could you give an example of what you are after?

"is there a way to pass more than one name in this variable: vaInputs.user.first_name?" This will be the first_name of the logged in user.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark, 

 

Yes, for example, using my user as example.

'https://webchat.servicedeskURL.com/?tenant=iss_companyID_gen_es_rc&firstName=' + vaInputs.user.first_name + '&lastName=' + vaInputs.user.last_name + '&email=' + vaInputs.user.email + '&login=' + vaInputs.user.email + '&client=iss_companyID_gen_es_rc&chatId=chat&languageCode=es&countryCode=es'


The URL above would be passed as:

'https://webchat.servicedeskURL.com/?tenant=iss_companyID_gen_es_rc&firstName='Luiz'&lastName='Lucena'&email='luiz.lucena@email.com'&login='luiz.lucena@email.com'&client=iss_companyID_gen_es_rc&chatId=chat&languageCode=es&countryCode=es'

However, if either the first or last name field contains more than one name, like "Jose Arturo" (first name field) and/or last name as "Diaz Dominguez", the URL is broken. I presume due the space in between the names.

Thanks, 

 

Ah oke clear what you mean with double name 🙂 I guess it could be that a name has multiple spaces?

You could replace the spaces. Have you tried that? Replacing the space with %20.

Something like:

vaInputs.user.first_name.replaceAll(' ', '%20')

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thanks, Mark!

 

That did the trick!