Alokai
You are reading the documentation for v7.x and earlier, which is no longer the latest version. Switch to v8.x

updateAndGetUser

Update customer profile and return it from SAP Commerce Cloud.

This method exchanges data with two endpoints exposed by the SAP OCC API: updateUser and getUser.

This method works only in an authenticated user session (i.e. when the vsf-sap-token cookie is present in the request). It only updates the fields provided in the user param.

Bear in mind the SAP OCC API updateUser endpoint does not allow for updating customer uid (login) and so does not this method.

Signature

export declare function updateAndGetUser(
	context: SapccIntegrationContext,
	props: UpdateAndGetUserProps
): Promise<User>;

Parameters

NameRequiredTypeDescription
contextRequiredSapccIntegrationContext
propsRequiredUpdateAndGetUserPropsParameter object which can be used with this method. Refer to its type definition to learn about possible properties.

Returns

Returns a representation of a User.

Referenced Types

Examples

Updating a customer profile.

import { UpdateAndGetUserProps } from '@vsf-enterprise/sapcc-types';
import { sdk } from '~/sdk';

const props: UpdateAndGetUserProps = {
  user: {
    firstName: 'John',
    lastName: 'Doe'
  }
}

const updatedUser = await sdk.commerce.updateAndGetUser(props);

Updating a customer profile and selecting response fields.

import { UpdateAndGetUserProps } from '@vsf-enterprise/sapcc-types';
import { sdk } from '~/sdk';

const props: UpdateAndGetUserProps = {
  user: {
    firstName: 'John',
    lastName: 'Doe'
  },
  fields: 'firstName,lastName'
}

const updatedUser = await sdk.commerce.updateAndGetUser(props);

On this page