Concatenating variables in onClick events: what am I doing wrong?

Could anyone please advise where I'm going wrong with the following onClick event:

[...]
var x = 'BO.';
var y = 'page.';

var a = x + 'F_Shortname';
var b = BO.F_Shortname.getValue(); // Results are correct
var c = a.getValue(); // This breaks - see below

-------------------------------------------

When testing, 'b' works correctly however, 'c' fails with the below error:

[...]
Caused by: TypeError: a.getValue is not a function

Best regards
Stephen

Hi @Stephen Doe

You have converted the BO object to a String, so it will not work. It should remain as an Object then only it will work.
You can code it as follows, then it will work.
var x = BO;
var y = page;

var a = x.F_Shortname;
var b = BO.F_Shortname.getValue();
var c = a.getValue();

I hope this helps.

Kind Regards

Abhay

Completely brilliant; thank you so much!

Hi @Abhay Shirke,

in using your methodology, is there any way in which I can extract the BO object's internal ID and concatenate it together with other variables?

Best regards
Stephen

[...]
var x = BO;
var y = page;
var z = x.F_Shortname.getId(); //Returns: F_Shortname

var a = x.z.getValue();
var b = y.z.getTitle();

Caused by: TypeError: x.z is undefined

Hi @Stephen Doe

In my opinion, this methodology will not work when we are using the functions/methods ( for example: getID() ). It will work until we use the Objects (BO, page, app, item, etc). I have no idea how to make it work with functions/methods.

You can create a new question post for this. Probably someone from Volt Development Team can reply on this.

Kind Regards

Abhay

Many thanks again for your input, it#s much appreciated.

Best regards
Stephen

No problem. My pleasure.

Kind Regards

Abhay