cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

How to clear/remove array in sessionStorage

AP_10343008
16-Pearl

How to clear/remove array in sessionStorage

 
I am storing array in sessionstorage. I'm able to update the array using 
sessionStorage.setItem(Op_withoutSpaces + "_" + i, array);
 
but i couldn't remove or clear the array in sessionstorage using below code. 
sessionStorage.clear(Op_withoutSpaces + "_" + i);
sessionStorage.RemoveItem(Op_withoutSpaces + "_" + i);
 
Let me know what is wrong in this.
ACCEPTED SOLUTION

Accepted Solutions

Hi @AP_10343008,

 

First of all, TW.sessionStorage.clear() function doesn't accept any arguments, this function will clear ALL items in sessionStorage.

Refer to MDN document.

So you are not supposed to pass anything in the parenthesis like below.

TW.sessionStorage.clear(Op_withoutSpaces + "_" + i);

Secondly, can you try removing other code and passing hard-coded key name to TW.sessionStorage.RemoveItem("key") instead of parameter for testing purpose?

I tested both TW.sessionStorage.clear and TW.sessionStorage.RemoveItem("key") in expression and both work just fine.

 

Tony

View solution in original post

4 REPLIES 4

Hi @AP_10343008  can you use it in the format below?

TW.sessionStorage.removeItem()
TW.sessionStorage.clear()

Still it is not working. I uploaded the code which written in the expression of mashup. Kindly take a look.

 

 

Anyone knows why remove item is not working in session ? Please find the code i have attached.

Hi @AP_10343008,

 

First of all, TW.sessionStorage.clear() function doesn't accept any arguments, this function will clear ALL items in sessionStorage.

Refer to MDN document.

So you are not supposed to pass anything in the parenthesis like below.

TW.sessionStorage.clear(Op_withoutSpaces + "_" + i);

Secondly, can you try removing other code and passing hard-coded key name to TW.sessionStorage.RemoveItem("key") instead of parameter for testing purpose?

I tested both TW.sessionStorage.clear and TW.sessionStorage.RemoveItem("key") in expression and both work just fine.

 

Tony
Announcements


Top Tags