Sales rep Information’s on my account information section .

To get a  Sales rep Information’s on my account information section we need to extend the corresponding view and add the fetch method to get the data from the customer record then create a field in the template file and store the data in a variable and pass the variable to templet file

code:

 _.extend(OverviewProfileView.prototype, {
        template: jj_MyAccount_Custom_MyAccountShowidCustom_tpl
      })
      var profile_data = profilemodel.getInstance();
      var service_url = Utils.getAbsoluteUrl(
        getExtensionAssetsPath("services/MyAccountShowidCustom.Service.ss")
      );
      var cust_id = profile_data.get("internalid");
      console.log("cust_id", cust_id);
      jQuery.get(service_url, { cust_id: cust_id }).then(function (result) {
        console.log('result',result);
        var layout = container.getComponent("Layout");
                    layout.addToViewContextDefinition
                    ("Overview.Profile.View", 
                    "Sales_data", 
                    "string", 
                    function (context) {
                        return result;
                    });
      });

suite script file

define("JJ.MyAccount_Custom.MyAccountShowidCustom", [
  "SC.Model"
], function (
  SCModel
  
) {
  "use strict";
  return SCModel.extend({
    salesRep: function (Cust_id) {
      console.error("prashanth", Cust_id);
      try {
        var customerSearch = nlapiSearchRecord("customer",null,
        [["internalidnumber","equalto",Cust_id]], 
        [
          new nlobjSearchColumn("salesrep"), 
          new nlobjSearchColumn("email","salesRep", null), 
          new nlobjSearchColumn("phone","salesRep", null)
        ]
        );
      } catch (error) {
        nlapiLogExecution('ERROR', 'ERROR_SSP_LIBRARIES_EXT', JSON.stringify(customerSearch));
      }
      var sales_id;
      var sales_email;
      var sales_phone;
      try {
        if (customerSearch) {
          for (var j = 0; j < customerSearch.length; j++) {
            var searchresult = customerSearch[j];
            sales_id = searchresult.getText("salesrep");
            sales_email = searchresult.getValue("email", "salesRep");
            sales_phone = searchresult.getValue("phone", "salesRep");
          }
        } 
      } catch (error) {
        nlapiLogExecution('ERROR', 'customersearcherror', JSON.stringify(customerSearch));
      }
      console.error("sales_id", sales_id);
      console.error("sales_email", sales_email);
      console.error("sales_phone", sales_phone);
      return {
        Sales_Id: sales_id,
        Sales_Email: sales_email,
        Sales_Phone: sales_phone,
      };
    },
  });
});

Leave a comment

Your email address will not be published. Required fields are marked *