new UserProfile()

Description

The UserProfile component enables you to retrieve information about the current web store visitor. The information available depends on whether the visitor is currently logged in, is a registered user but is not logged in, or is an unregistered user.

Create an instance of this component by calling container.getComponent("UserProfile").

Details

SuiteCommerce 2019.1

Members


componentName :String

Description

A unique name that identifies the component. Use the component name when getting a component, for example, application.getComponent(componentName).

Details
String

application :ComponentContainer

Description

The name which identify this kind of component. This name is used both for registering a new component and
getting a component implementation with ComponentContainer

Details

Methods


cancelableOn( event_name, handler ) → {void}

Description

Attaches an event handler to an event.

Parameters
Name Type Description
event_name String

The name of the event to which the event handler will be attached.

handler function

The event handler method that will be invoked when event_name is triggered. This function can receive optionally one parameter representing the action parameter. Besides optionally can return a Deferred to details the execution of the trigger's callback. If the returned Deferred is rejected the trigger's callback wont be called

Returns
Details

cancelableOff( event_name, handler ) → {void}

Description

Detaches an event handler from an event.

Parameters
Name Type Description
event_name String

The name of the event from which to detach the event handler. This argument is required.

handler function

The event handler that will be removed from the list of handlers attached to the event. This argument is required.

Returns
Details

extend( componentDefinition ) → {BaseComponent}

Description

Extends the current component and creates a child component.

Parameters
Name Type Description
componentDefinition Object

An object with the appropriate properties and methods to create the component.

Returns
Details

getUserProfile() → {UserProfileData}

Description

Gets read-only information about the current web store visitor. If the visitor is logged in as a user, you can get details such as the user's first name and last name, the user's addresses, credit limit, current balance, and more. Refer to the UserProfileData object for a list of all properties.

If a web store visitor is not logged in, this method returns a smaller set of properties. Note that visitors may be recognised even if they are not logged in. You can check for this with the isrecognized property of the UserProfileData object.

This method returns a predefined set of fields from the customer record in NetSuite, as specified in the UserProfileData object definition. It may also return custom fields from the customer record. Custom fields are returned only if the Web Site box is checked on the Applies To tab on the custom field record. See Creating a Custom Field in the NetSuite Help Center for more information about how to create custom fields.

var userprofilecomponent = container.getComponent("UserProfile");
			
			userprofilecomponent.getUserProfile().then(function(profile) {
			    firstname = profile.firstname;
			    lastname = profile.lastname;
			    fullname = firstname + " " + lastname;
			
			    console.log("User: Full Name: " + fullname);
			});
			
Returns

Returns a Deferred object. If the promise is resolved, it returns a UserProfileData object with a set of predefined properties. Otherwise, the promise is rejected.


cancelableDisable( event_name ) → {void}

Description

Disables all the event handlers attached to an event.

Parameters
Name Type Description
event_name String

The name of the event.

Returns
Details

on( event_name, handler ) → {void}

Description

Attaches an event handler to an event name. Alias for CancelableEvents#cancelableOn.

Parameters
Name Type Description
event_name String

The name of the event to attach to

handler function
Returns
Details

cancelableEnable( event_name ) → {Void}

Description

Re-enables all the event handlers attached to an event.

Parameters
Name Type Description
event_name String

The name of the event.

Returns
Details

off( event_name, handler ) → {void}

Description

Detaches an event handler from an event name. Alias for CancelableEvents#cancelableOff.

Parameters
Name Type Description
event_name String

The name of the event from which to detach the event handler.

handler function
Returns
Details

cancelableTrigger( event_name, ...args ) → {Deferred}

Description

Triggers an event with a set of arguments. If an event handler is rejected, the event handler callbacks will not be executed.

Parameters
Name Type Attributes Description
event_name String

The name of the event to trigger.

args params <repeatable>

One or more arguments that will be broadcast to all event handlers attached to the event.

Returns

Returns a Deferred object. Because event handlers are sometimes asynchronous, any callbacks in the event handlers will also be asynchronous.

Details

cancelableTriggerUnsafe( event_name, ...args ) → {Deferred}

Description

Triggers an event with a set of unsanitized arguments. If an event handler is rejected, the event handler callbacks will not be executed.

Parameters
Name Type Attributes Description
event_name String

The name of the event to trigger.

args params <repeatable>

One or more arguments that will be broadcast to all event handlers attached to the event.

Returns

Returns a Deferred object. Because event handlers are sometimes asynchronous, any callbacks in the event handlers will also be asynchronous.