Highlighted
Absent Member.
Absent Member.
790 views

javascript error

Jump to solution

Hello Experts,

 

I need to retrieve the corresponding catalog id from the catalog name passed as a parameter from the javascript called from format control. But while executing it is throwing an error as

 

Script 'newInsert'  line 15: ERROR Cannot store a string into an object of type number at char 1
and the line 15 is--- cart.svcCatalogId=newcart.id;.
 
Please can anyone suggest me how shud i rectify this error.
 
Thanks.
 
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi,

 

The error is thrown because you're saving a string value into a numeric field. I suggest you change the data type of the value before you assign it. You can use some JavaScript functions to change the value, as below:

 

cart.svcCatalogId=parseInt(newcart.id);

 

I have no access to a SM env so I'm not able to test this, however I think it's close to the solution.

View solution in original post

7 Replies
Highlighted
Absent Member.
Absent Member.

Hi

 

To call a particular Service Manager variable into memory. Use system.vars

For example, your code can be rewritten as

 

       cart.svcCatalogId=system.vars.newcart_id;

0 Likes
Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..
You should be able to use the system.functions.val() rad function to retype the newcart.id as a number type. Look in your helpserver documentation for usage on the val() function and "data types".
0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Hello

Can you post teh whole script?

newcart.id is  variable which you created in script? Or is it a field from somewhere?

If it is created by you in script then probably you have missed in the begining var newcart.id;

0 Likes
Highlighted
Absent Member.
Absent Member.

Hello Vadim,

 

Thanks for the response.

 

Here is the script attached for your reference.

 

0 Likes
Highlighted
Acclaimed Contributor.. Acclaimed Contributor..
Acclaimed Contributor..

Hello again,

svcCatalogID in svcCartItem table, is a number data type field and  id field in svcCatalog is character.

 

You wont be able to input a character field in number field even with using val. As you will get null at conversion of character to number.

 

Suppose you will have to copy it to other field

0 Likes
Highlighted
Absent Member.
Absent Member.

Hi Vadim,

 

This is exactly what i recieved . A null result. I will have the value copied to another field and then try again if not will post for help.

 

Thanks again.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Hi,

 

The error is thrown because you're saving a string value into a numeric field. I suggest you change the data type of the value before you assign it. You can use some JavaScript functions to change the value, as below:

 

cart.svcCatalogId=parseInt(newcart.id);

 

I have no access to a SM env so I'm not able to test this, however I think it's close to the solution.

View solution in original post

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.