Live Helper Chat support forum.. Old google groups forum can be found here

You are not logged in.

Announcement

#1 2021-01-24 06:00:54

Sajad2010
New member
Registered: 2020-11-30
Posts: 6

Execute JS - variables

Hi,
I want change persian/arabic digits to english in custom attribute,
I'm running this javascript:

[== JavaScript ==]
var abc = "۱۲۳۴۵۶۷۸۹۰";
console.log(
	abc.replace(/[٠-٩]/g, d => "٠١٢٣٤٥٦٧٨٩".indexOf(d)).replace(/[۰-۹]/g, d => "۰۱۲۳۴۵۶۷۸۹".indexOf(d))
);

I'm trying to use {lhc.add.myVar} instead of "abc", This is error:  SyntaxError: Unexpected token '.'
I can use custom attribute in "Execute JS" ?
Thanks

Offline

#2 2021-01-25 06:54:27

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,481
Website

Re: Execute JS - variables

Please apply this change. And exeute js will support replaceable variables as other blocks smile

https://github.com/LiveHelperChat/liveh … 8cc43f8e92

Offline

#3 2021-01-25 07:53:57

Sajad2010
New member
Registered: 2020-11-30
Posts: 6

Re: Execute JS - variables

remdex wrote:

Please apply this change. And exeute js will support replaceable variables as other blocks smile


Very Very GOOD  wink  wink
Can i rewrite new string to custom attribute in execute js ? How ?

Offline

#4 2021-01-25 07:55:17

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,481
Website

Re: Execute JS - variables

Offline

#5 2021-01-25 08:11:16

Sajad2010
New member
Registered: 2020-11-30
Posts: 6

Re: Execute JS - variables

remdex wrote:

Use any of these in JS body.

Thanks for reply
My mean is use {lhc.nick} in left-hand

for exam:
{lhc.nick} = "JohnDoe";  in Execute JS

Offline

#6 2021-01-25 08:17:58

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,481
Website

Re: Execute JS - variables

This won't work. They are used to fetch attribute, not set. To set attribute you have to use https://doc.livehelperchat.com/docs/cus … d-prefill/

Offline

#7 2021-01-25 08:53:46

Sajad2010
New member
Registered: 2020-11-30
Posts: 6

Re: Execute JS - variables

my senario is :

get nick of user,
execute js to find special character and replace them,
now i want rewrite new string to nick again,

i don't know how to get new string from 'execute js'
execute js can return my new string ?
can i set directly write to lhc.nick or lhc.add.myVar ?

can you help me with an example ?

Offline

#8 2021-01-25 09:08:04

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,481
Website

Re: Execute JS - variables

For that you should use extension to replace user entered nick.
https://doc.livehelperchat.com/docs/hoo … ing-a-chat

Offline

#9 2021-01-26 07:02:55

Sajad2010
New member
Registered: 2020-11-30
Posts: 6

Re: Execute JS - variables

very good, that's useful angel
what about other parameters ? for example lhc.add.myVar
lhc.add.myVar received from Collect custom attribute

Offline

#10 2021-01-26 07:03:35

remdex
Administrator
From: Lithuania
Registered: 2012-09-23
Posts: 3,481
Website

Re: Execute JS - variables

Read documentation...

Offline

Board footer