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

Muralidharan BS
Mega Sage
Mega Sage

Hi Luiz, 

can you try this, before sending the first and last name replace the space with "%20" this is the URI for spaces?

vaInputs.user.first_name.trim().replace(' ', '%20')

vaInputs.user.last_name.trim().replace(' ', '%20')

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

 

Thanks