on 2015 Mar 26 6:16 AM
Hi All,
Does anyone know why this works:-
var TW = "36" ;
// Calculate the Shopper Stats
var ITEM_VAR = SHOPPER_STATS.getData("BASKET_ITEM_AVG", {"WEEK_NUM": TW }).value
But when I try to use a variable such as
// Get the max week
var WEEK_ARRAY = SHOPPER_STATS.getMembers("WEEK_NUM", 300) ;
var MAX_WEEK = 0 ;
WEEK_ARRAY.forEach(function(element, index) {
if (Convert.stringToInt(element.text) > MAX_WEEK) {
MAX_WEEK = Convert.stringToInt(element.text) ;
}
}) ;
// Set this week and last week
var TW = MAX_WEEK+"" ;
// Calculate the Shopper Stats
var ITEM_VAR = SHOPPER_STATS.getData("BASKET_ITEM_AVG", {"WEEK_NUM": TW }).value
I get the error "Wrapped java.lang.NullPointerException: while trying to invoke the method java.lang.String.startsWith(java.lang.String) of a null object loaded from local variable 'memberKey'"
I have put TW into an alert and the number is shows me is 36 so I know that is the same.
Cheers,
James.
Request clarification before answering.
can you try to find the line which is breaking the code (by commenting the lines - line by line).
check also the line:
var TW = MAX_WEEK+"" ;
should not be
var TW = "" + MAX_WEEK;
-> this should convert it to string, I do not know if your line is working correctly.
what is actually the value of "TW" at the end?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
strange, this remands me on an issue where Strings were not correctly transformed. there was some thread in 1.4 SP0 on this, should be fixed in patch2, latest in 1.4 SP1. What are you on?
try this (just to check the situation):
1.
// this will not change the value itself, but can change the internal type of the variable...
var TW2 = TW.substring(0, TW.length);
2. other option.
* place somewhere a TEXT component and make additionally following.
TEXT_1.setText(TW2);
var TW3 = TEXT_1.getText();
option 2 definitelly will return a string.
now, pass the TW2 or TW3 to the function.
will this work?
Karol
User | Count |
---|---|
58 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.