cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript "ReferenceError: Invalid left-hand side in assignment"

SOLVED
Highlighted
Contributor

JavaScript "ReferenceError: Invalid left-hand side in assignment"

I am trying to set a value in cell in a local table variable.  I have done this in C# but I can't make it work in JavaScript.  Nothing I have tried so far works....  It has to be something simple.  Thanks!!!

 

KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults").SQLHeaderID(int_RowNumber) = 123456;

Or 

 var t = KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults");
 t.Item(6,0) = 123456;

Or

 var t = KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults");
 t.Item("SQLHeaderID",0) = 123456;

Or

 var t = KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults");
 t.SQLHeaderID(0) = 123456;

PS...  Another variation...

  let t;
  t = KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults");
  t.SQLHeaderID(0) = 123456;
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

@AlexKaras   Thanks, I could not get $set to work.  However,  aqObject.SetPropertyValue worked well.  

 

// Get Ref to Table
var t = KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults");  
//Write values to the KWT table  
aqObject.SetPropertyValue(t, "SQLHeaderID", int_RowNumber, var_aSQLHeaderID)

Here t is a reference to my table object, SQLHeaderID is the column name property, int_RowNumber is the, well, rownumber Smiley Happy and var_aSQLHeaderID is the value I want to write to the local table in my keyword test.

 

Thanks for all the help guys!

View solution in original post

6 REPLIES 6
Highlighted
Community Hero

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

Hi,

 

can't make it work in JavaScript.

Try to use .$set() method as described here: https://support.smartbear.com/testcomplete/docs/reference/language/javascript/set-method.html

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
Community Leader

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

Hi,

 

Do I understand You clearly You are working with the "Temporary variable" with the "Table" type?

 

Or this is some kind of another variable?

Highlighted
Contributor

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

Yes, this is a table type variable in a keyword test.

 


@Wamboo wrote:

Hi,

 

Do I understand You clearly You are working with the "Temporary variable" with the "Table" type?

 

Or this is some kind of another variable?


 

Highlighted
Contributor

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

Interesting,  I will give this a try.  Thanks!

 


@AlexKaras wrote:

Hi,

 

can't make it work in JavaScript.

Try to use .$set() method as described here: https://support.smartbear.com/testcomplete/docs/reference/language/javascript/set-method.html

 


 

Highlighted
Community Hero

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

To follow up with @AlexKaras  suggestion, here's the documentation to go along with it.

https://support.smartbear.com/testcomplete/docs/scripting/specifics/javascript.html#indexed-properti...

 

Basically, because the cell of the table is an "indexed property", you need to use the $set method to set the value.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Contributor

Re: JavaScript "ReferenceError: Invalid left-hand side in assignment"

@AlexKaras   Thanks, I could not get $set to work.  However,  aqObject.SetPropertyValue worked well.  

 

// Get Ref to Table
var t = KeywordTests.Move_Order.Variables.VariableByName("tbl_QueryResults");  
//Write values to the KWT table  
aqObject.SetPropertyValue(t, "SQLHeaderID", int_RowNumber, var_aSQLHeaderID)

Here t is a reference to my table object, SQLHeaderID is the column name property, int_RowNumber is the, well, rownumber Smiley Happy and var_aSQLHeaderID is the value I want to write to the local table in my keyword test.

 

Thanks for all the help guys!

View solution in original post

New Here?
Join us and watch the welcome video:
Read the Latest News
JuneSCNJ
Top Kudoed Authors