Back to Kodaris

Mapping New Company Accounts to ERP

Overview

This document outlines the standard operating procedures for mapping new company accounts to ERP.
When a company account in Kodaris is saved to the ERP, the system runs a script for mapping the account fields to the Infor CSD ERP.
In the Kodaris system, this script is called an interceptor.
If that company account is a new account and if it's being saved to the ERP for the first time, it runs an interceptor script called inforCSDARCustomerMntArscAdd.js
Let's see how this interceptor script works and how to use it to map the company fields.

Requirements

  • JavaScript knowledge
  • Infor CSD knowledge

Steps

1. Open the Interceptors page

Log in the Operations Portal. Type "interceptor" in the left menu search bar, then click Interceptors to open the page.

3344_01_interceptor_011.png
Operations Portal home page: type "interceptor" in the menu search bar
3344_01_interceptor_012_2.png
Click Interceptors to open the page
3344_01_interceptor_041_2.png
Interceptors page

2. Find the interceptor and open it

Open the Google Chrome Find tool: in the browser menu, click "Edit > Find > Find...".
Or press ⌘+F (Mac) / CTRL+F (Windows).

3344_01_interceptor_051_3.png
Google Chrome menu: click "Edit > Find > Find..."
3344_01_interceptor_06_1.png
Google Chrome Find tool

In the Find tool popup box, search for "inforCSDARCustomerMntArscAdd.js" and click the ">" icon to open it.

3344_01_interceptor_071.png
Search for "inforCSDARCustomerMntArscAdd.js" in the Find tool and open it
3344_01_interceptor_081.png
inforCSDARCustomerMntArscAdd.js interceptor script page

3. Change the interceptor script and save it

In order to do the field mapping for request to add a customer to Infor CSD, it uses the companyID in scope to get the company:

var company = kd.api.fetch({
  method: 'GET',
  endpoint: '/api/system/company/{companyID}',
  pathParams: {"companyID": companyID}
});

Then, if there is a company, an API call body can be defined using the requestBody variable:

if(company) {
  requestBody = {
    "tMntTt": {
      "t-mnt-tt": [
        {
          "setno": 1,
          "seqno": 1,
          "updateMode": "add",
          "fieldname": "name",
          "fieldvalue": company.companyName
        },
        {
          "setno": 1,
          "seqno": 2,
          "updateMode": "add",
          "fieldname": "addr1",
          "fieldvalue": company.address1
        }
      ]
    }
  }
}

The requestBody variable is an object with a key named "tMntTt", and it's value is another object with another key named "t-mnt-tt".
The "t-mnt-tt" value is an array of objects for mapping the company fields, where each object will map one field as follows:

  • setno: all of the records, within the collection, are grouped together by a Set #. Each Set # represents a single operation that will be performed against the SX.enteprise system.
  • seqno: the seq # is just a sequential number that forces the collection rows to be read in a certain sequence within a set.
  • updateMode: determines the operation to perform and should be “add” for a new company, or “chg” to change/update a company that has already been saved in the ERP.
  • fieldname: is the field that will be updated within the SX.enterprise database table (ARSC or ARSS). See below for a complete list of values.
  • fieldvalue: is the value of the data for that field.
  • key1: is used to specify the Customer # during a “chg” operation. It can also be used during the “add” operation to specify the Customer # to be assigned (cannot be already used within SX) for the new customer being added. During an “add” operation, the “key1” field can be left blank and the next available Customer # will be used.
  • key2: is only used for a Ship To (ARSS) operation. That is, when adding, or changing a Ship To record, the Ship To identifier must be specified in “key2”.

The following is a list of valid “fieldname” values:

  • addonno1
  • addr1
  • apphoneno
  • bankacct
  • bankphoneno
  • cashrecfl
  • class
  • countrycd
  • crestdt
  • currencyty
  • custno2
  • custperiodbal3
  • custprodfl
  • custuncashbal
  • discytd
  • dunsno
  • easnto
  • edictrlno
  • edinetwork
  • ediyouraddr
  • epropto
  • faxphoneno
  • futinvbal
  • gencity
  • genzip
  • highsaleamt
  • inbndfrtfl
  • jobdesc
  • jobperiodbal1
  • jobperiodbal5
  • lastagedt
  • lastpaydt
  • lastrtg1
  • lastsaleamt
  • laststmtbal
  • lenaddr2
  • lenst
  • lienfileoper
  • lienprewith
  • mediacd
  • nextrevdt
  • nopastdue
  • other1cd
  • ownaddr2
  • ownst
  • periodbal1
  • periodbal5
  • pmcashfl
  • pricecd
  • rebatesytd
  • revestdt
  • salesterr
  • servchgbal
  • shiplbl
  • shipviaty
  • slslimitamt
  • startdt
  • statementty
  • taxablety
  • taxreg
  • unearnedfl
  • user3
  • user7
  • user11
  • user15
  • user19
  • user23
  • whse
  • addonno2
  • addr2
  • ardatccost
  • bankmgr
  • bofl
  • cashreqfl
  • codbal
  • countycd
  • crref1
  • custcodbal
  • custordbal
  • custperiodbal4
  • custservchgbal
  • cyclecd
  • divno
  • eackto
  • ecommwhse
  • edienvtag1
  • ediordcd
  • einvto
  • eproptype
  • fpcustfl
  • genaddr1
  • gennm
  • geocd
  • holddays
  • invtofl
  • jobfutinvbal
  • jobperiodbal2
  • jobservchgbal
  • lastcostytd
  • lastrebatesytd
  • lastrtg2
  • lastsaledt
  • laststmtdt
  • lenaddr3
  • lenzip
  • lienpreamt
  • linetermsfl
  • minord
  • noinv
  • nopay
  • other2cd
  • ownaddr3
  • ownzip
  • periodbal2
  • phoneno
  • pocontctnm
  • pricetype
  • rebatety
  • route
  • salesytd
  • servchgfl
  • shipreqfl
  • siccd1
  • slsrepin
  • state
  • statusdt
  • taxauth
  • tendqtyfl
  • unearnedytd
  • user4
  • user8
  • user12
  • user16
  • user20
  • user24
  • wodisccd
  • addonno3
  • addr3
  • ardatcty
  • banknm
  • bondedfl
  • city
  • comment
  • creditmgr
  • crref2
  • custfutinvbal
  • custperiodbal1
  • custperiodbal5
  • custshipto
  • dealer
  • downpayamt
  • eacktype
  • ediackver
  • edienvtag2
  • edipartaddr
  • einvtype
  • estcompdt
  • fpcustno
  • genaddr2
  • genphoneno
  • gstcert
  • holdfl
  • jobclosedt
  • jobmisccrbal
  • jobperiodbal3
  • jobuncashbal
  • lastdiscytd
  • lastreturnsytd
  • lastrtgdt1
  • lastsalesytd
  • lastunearnedytd
  • lencity
  • lienamt
  • lienpredt
  • lookupnm
  • misccrbal
  • noinvcopy
  • ordbal
  • outbndfrtfl
  • owncity
  • pastduedt
  • periodbal3
  • pickprno
  • pophoneno
  • prstmtbal
  • restrictfl
  • salesamt
  • securfl
  • servchgytd
  • shipto
  • siccd2
  • slsrepout
  • statecd
  • statustype
  • taxcert
  • termstype
  • user1
  • user5
  • user9
  • user13
  • user17
  • user21
  • webpage
  • zipcd
  • addonno4
  • apmgr
  • avgpaydays
  • bankno
  • bondno
  • citycd
  • costytd
  • credlim
  • crsname
  • custmisccrbal
  • custperiodbal2
  • custpo
  • custtype
  • disccd
  • dunningfl
  • easngrp
  • edichgcd
  • ediinvver
  • edipartner
  • email
  • estmttype
  • futbal
  • genaddr3
  • genst
  • gstreg
  • holdpercd
  • jobcodbal
  • jobordbal
  • jobperiodbal4
  • langcd
  • lastpayamt
  • lastrevdt
  • lastrtgdt2
  • lastservchgytd
  • lenaddr1
  • lennm
  • lienfiledt
  • lienpreoper
  • maxord
  • name
  • nontaxtype
  • orderdisp
  • ownaddr1
  • ownnm
  • pdcustno
  • periodbal4
  • pickprtfl
  • poreqfl
  • rebatesdue
  • returnsytd
  • salesmgrfl
  • selltype
  • shipinstr
  • shiptoeasncd
  • siccd3
  • spcdefaultty
  • stagecd
  • subfl
  • taxdt
  • uncashbal
  • user2
  • user6
  • user10
  • user14
  • user18
  • user22
  • webpageext

Fields required in order for the record to function in CSD:

  • credlim
  • lookupnm
  • name
  • sellType
  • slsrepout
  • statecd
  • taxablety
  • termstype

There is validation on many fields that values must match configurations in CSD which are not added here but in CSD docs.

Kodaris Model:

{
  "accountPaymentMethods": "ALL",
  "accountsPayableManager": "string",
  "accountsPayablePhone": "string",
  "active": true,
  "address1": "string",
  "address2": "string",
  "address3": "string",
  "approvalFlowTwoLevel": true,
  "backorder": true,
  "bankAccount": "string",
  "bankManager": "string",
  "bankName": "string",
  "bankNumber": "string",
  "bankPhoneNumber": "string",
  "businessType": "string",
  "canUsePOs": true,
  "canViewPricing": true,
  "city": "string",
  "codBalance": 0,
  "code": "string",
  "companyCanUseCreditCards": 0,
  "companyCustomerType": "ACH",
  "companyGroupCode": "string",
  "companyName": "string",
  "companyType": "string",
  "cono": 0,
  "costYTD": 0,
  "country": "string",
  "creator": "string",
  "creditCardExpiration": "string",
  "creditCardNumber": "string",
  "creditEstablishedDate": "string",
  "creditLastReviewedDate": "string",
  "creditLimit": 0,
  "creditManagerCode": "string",
  "creditNextReviewDate": "string",
  "creditReferences": "string",
  "creditSourceName": "string",
  "currencyCode": "string",
  "customerDefaultPONumber": "string",
  "customerGroupCode": "string",
  "customerProductGroupCode": "string",
  "customerType": "string",
  "customerTypeDescription": "string",
  "cycleCode": "string",
  "cycleDescription": "string",
  "dealer": "string",
  "defaultEmployeeSpendingLimit": 0,
  "defaultShipViaCode": "string",
  "defaultWebWarehouse": "string",
  "deliveryRadius": 0,
  "discountGracePeriod": "5",
  "discountIDCode": 0,
  "discountYTD": 0,
  "dollarCreditCardFee": "string",
  "dunAndBradStreetNumber": "string",
  "email1": "string",
  "email2": "string",
  "externalCompanyCode": "string",
  "externalID": "string",
  "extra1": "string",
  "extra2": "string",
  "extra3": "string",
  "extra4": "string",
  "futureBalance": 0,
  "futureInvoiceBalance": 0,
  "generalLedgerAccountNumber": "string",
  "generalLedgerDepartmentNumber": "string",
  "generalLedgerDivisionNumber": "string",
  "generalLedgerSubAccountNumber": "string",
  "geoCode": "string",
  "highBalance": 0,
  "hostCode": "string",
  "inboundFreight": true,
  "industryCode": "string",
  "insideSalesRepCode": "string",
  "invoicesNumberOfInvoices": 0,
  "languageCode": "string",
  "lastAgedDate": "string",
  "lastModifiedLocally": "string",
  "lastSaleDate": "string",
  "lastStatementBalance": 0,
  "lastStatementDate": "string",
  "latitude": 0,
  "legalStructure": "string",
  "logo": "string",
  "longitude": 0,
  "maximumOrder": 0,
  "minimumOrder": 0,
  "miscellaneousCreditBalance": 0,
  "monthlySalesVolume": "string",
  "nonTaxTypeDescription": "string",
  "nonTaxableCode": "string",
  "notes": "string",
  "orderBalance": 0,
  "outboundFreight": true,
  "outsideSalesRepCode": "string",
  "parentCompanyID": 0,
  "paymentAveragePaymentDays": 0,
  "paymentCustomerType": "Business",
  "paymentLastPaymentAmount": 0,
  "paymentLastPaymentDate": "string",
  "paymentNumberOfPayments": 0,
  "paymentNumberPastDue": 0,
  "paymentPastDueDate": "string",
  "paymentSystemCardAccount": "NONE",
  "paymentSystembankAccount": "ACH",
  "percentageCreditCardFee": "string",
  "periodBalances": "string",
  "phone1": "string",
  "phone2": "string",
  "postalCode": "string",
  "previousStatementBalance": 0,
  "priceIDCode": 0,
  "priceTypeCode": "string",
  "priceTypeDescription": "string",
  "priorityPaymentsCustomerId": "string",
  "purchaseOrderRequired": true,
  "quotePricingStatus": "string",
  "rebateType": "string",
  "rebatesDue": 0,
  "rebatesYTD": 0,
  "requestedCreditLimit": "string",
  "restrictedCatalog": true,
  "returnsYTD": 0,
  "safetyTaskForceCompany": 0,
  "salesTerritoryCode": "string",
  "salesTerritoryDescription": "string",
  "salesYTD": 0,
  "serviceChargeBalance": 0,
  "serviceChargeYTD": 0,
  "shippingInstructions": "string",
  "shiptoCode": "string",
  "spendingLimitEnabled": true,
  "state": "string",
  "status": "string",
  "taxableType": "string",
  "taxableTypeDescription": "string",
  "termstype": "string",
  "termstypeDescription": "string",
  "unCashedBalance": 0,
  "unearnedYTD": 0,
  "user1": "string",
  "user10": "string",
  "user2": "string",
  "user3": "string",
  "user4": "string",
  "user5": "string",
  "user6": "string",
  "user7": "string",
  "user8": "string",
  "user9": "string",
  "warehouseCode": "string",
  "website": "string"
}

The following is a complete code example to do the field mapping for request to add a customer to Infor CSD.
It can be changed to map other fields as needed:

app.log("Calling CSD Customer add function");

var company = kd.api.fetch({
  method: 'GET',
  endpoint: '/api/system/company/{companyID}',
  pathParams: {"companyID": companyID}
});

if (company) {
  var tMntTtList = app.createNewList();
  
  tMntTtList.add({
    "setno": 1,
    "seqno": 1,
    "updateMode": "add",
    "fieldname": "name",
    "fieldvalue": company.companyName
  });

  tMntTtList.add({
    "setno": 1,
    "seqno": 2,
    "updateMode": "add",
    "fieldname": "addr1",
    "fieldvalue": company.address1
  });

  tMntTtList.add({
    "setno": 1,
    "seqno": 3,
    "updateMode": "add",
    "fieldname": "city",
    "fieldvalue": company.city
  });

  tMntTtList.add({
    "setno": 1,
    "seqno": 4,
    "updateMode": "add",
    "fieldname": "zipcd",
    "fieldvalue": company.postalCode
  });

  tMntTtList.add({
    "setno": 1,
    "seqno": 5,
    "updateMode": "add",
    "fieldname": "countrycd",
    "fieldvalue": company.country
  });

  tMntTtList.add({
    "setno": 1,
    "seqno": 6,
    "updateMode": "add",
    "fieldname": "phoneno",
    "fieldvalue": company.phone1
  });

  requestBody = {
    "tMntTt": {
      "t-mnt-tt": tMntTtList
    }
  }
}

Here it uses a "tMntTtList" var with the app.createNewList() function assigned to it for creating a new list of fields to map.
Then, it keeps adding objects for each company field with tMntTtList.add.
In the end, remember to pass it into the requestBody object to set it to the API request for adding the company to the ERP.

After editing the interceptor script, click Save.

3344_01_interceptor_091.png
Save the interceptor script

4. Open the Companies page

Type "companies" in the left menu search bar, then click Companies to open the page.

3344_02_companies_011.png
Type "companies" to search the menu, then click to open the Companies page
3344_02_companies_021.png
Companies page

5. Open a Company details page

Find a new company (that was note saved to ERP yet) then click the ">" icon to open it.

3344_02_companies_031.png
Click ">" to open the company details page

6. Save to ERP

Click the icon Save to ERP icon to "Save to ERP".

3344_02_companies_041.png
Company details page: click the icon to "Save to ERP"
3344_02_companies_051.png
"Saved to ERP" success message

7. Open the System Events page

Type "system events" in the left menu search bar, then click System Events to open the page.

3344_04_system_ev_011.png
Type "system events" to search the menu, then click to open the System Events page
3344_04_system_ev_021.png
System Events page

8. Find the related system event and view the request data

The system event related to the ERP request has a name similar to "CSD_API_sxapiARCustomerMnt_1769686766490_request".
Find the more recent system event with this name pattern and click the icon View icon to view the request data.

3344_04_system_ev_031.png
Click the icon to view the system event request data

9. Check the request data

The request data must match the data in the system.

3344_04_system_ev_041.png
Request data
In this article