Anup Chaudhary
Anup Chaudhary

Reputation: 320

SuiteCommerce Advanced: Model Undefined issue on my account page.

I am very new to Netsuite's Suite Commerce Advanced,

I have created custom entity field(dob) and assigned to customer records, I am trying to save this custom field and it is working too.

But on My Account page I am unable to access these field. As in console it showing me error undefined

var first_name = this.model.get('firstname') || ''
        ,   middle_name = this.model.get('middlename') || ''
        ,   last_name = this.model.get('lastname') || ''
        ,   company_name = this.model.get('companyname') || ''
        ,   dob = this.model.get('custentity_dob');

Do I need to initialise model? and where?

Upvotes: 0

Views: 461

Answers (1)

Romeo
Romeo

Reputation: 149

It will not automatically display in your model. You still need to attached it in the Profile.Model

Ex.

_.extend(ProfileModel, {
    getCustomField: function getCustomField() {
        var customFields;
        var customFieldValue = [];

        if (CommerceAPI.session.isLoggedIn2()) {
            customFields = customFieldsParser(CommerceAPI.customer.getCustomFieldValues());
            customFieldValue = JSON.parse(customFields.custentity_dob);
        }

        return customFieldValue;
    }
});

    Application.on('after:Profile.get', function afterProfileGet(Model, responseData) {
        var customFieldValue = Model.getCustomField();

        responseData.customFieldValue = _.pluck(customFieldValue, 'value').toString();
        responseData.customFieldId = _.pluck(customFieldValue, 'id').toString();
    });

That will be done under your SuiteScript Folder at the backend files.

Upvotes: -1

Related Questions