NetSuite - Check if user is properly logged

拜拜、爱过 提交于 2019-12-12 00:27:24

问题


I have a little question. I am working with NetSuite eCommerce and I need to check something, my site runs a script when user is logged, but sometimes it asks for a login even when still getting NetSuite Attributes. Something like this:

var loginEmail = "<%=getCurrentAttribute('customer','email')%>";
if(loginEmail==null || loginEmail=="") {
   $("#cart").hide();
}
else {
   $("#cart").show();
}

Do you know a specific NetSuite attribute or tag that I should be calling/using?


回答1:


User sessions do time out after a period of inactivity, and user sessions are tracked with a cookie.

Try testing with a different browser - ie run NetSuite in FireFox and test the eCommerce functionality in Chrome or Safari, for instance.




回答2:


Try nlapiGetLogin(). From NetSuite Help:

nlapiGetLogin

Returns the NetSuite login credentials of currently logged-in user.

This API is supported in user event, portlet, Suitelet, RESTlet, and SSP scripts. For information about the unit cost associated with this API, see API Governance.

Returns nlobjLogin

Since Version 2012.2

Example

This example shows how to get the credentials of the currently logged-in user.

//Get credentials of currently logged-in user
var login = nlapiGetLogin();

It doesn't say, but my thought is that this would return null if no user is logged in.




回答3:


Use this code:

<%
var shoppingSession = nlapiGetWebContainer().getShoppingSession();

if (!shoppingSession.isLoggedIn()) 
    $("#cart").hide();
else
    $("#cart").show();
%>



回答4:


In place of

<%=getCurrentAttribute('customer','email')%>

try using

<%=getCurrentAttribute('customer','entityid')%>


来源:https://stackoverflow.com/questions/17455901/netsuite-check-if-user-is-properly-logged

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!