# How to create a JE in NS from OrderLines from SF?

**URL:** <https://connective.celigo.com/t/how-to-create-a-je-in-ns-from-orderlines-from-sf/6380>\
**Category:** Integrator.io\
**Tags:** transformation\
**Created:** [July 9, 2026, 11:40am UTC](https://connective.celigo.com/t/how-to-create-a-je-in-ns-from-orderlines-from-sf/6380 "2026-07-09T11:40:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anshul\_Gupta](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/anshul_gupta/32/9539_2.png) [@Anshul\_Gupta](https://connective.celigo.com/u/Anshul_Gupta)\
**Post date:** [July 9, 2026, 11:40am UTC](https://connective.celigo.com/t/how-to-create-a-je-in-ns-from-orderlines-from-sf/6380/1 "2026-07-09T11:40:46Z")

</div>

I am trying to import salesorderitems from SF.

Then i am trying to create a credit and debit line for every order line item using a transformation.

I am using a transformation using javascript shown below but it doesnt seem to work.

 ![image](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/f/f0071b1fd40bc85fdabb337c1c9bfda8b3ee59f1.png)

This is how orderlines looks like for a salesorder

```auto
{
  "page_of_records": [
    {
      "record": {
        "attributes": {
          "type": "s_c __Payment__ c",
          "url": "/services/data/v61.0/sobjects/s_c __Payment__ c/a10V100000Kqx3iIAB"
        },
        "Id": "a10V100000Kqx3iIAB",
        "Name": "Payment-1048492",
        "s_c __Order_Id__ c": "801V100000nR3fEIAS",
        "Order_Number__c": "01825890",
        "Deposit_Account__c": "10302",
        "Cash_Sale__c": true,
        "Customer_Deposit__c": true,
        "s_c __Amount__ c": 159.75,
        "Order_Paid_In_Full__c": true,
        "Batch_ID__c": "1055493750"
      }
    },
    {
      "record": {
        "attributes": {
          "type": "s_c __Payment__ c",
          "url": "/services/data/v61.0/sobjects/s_c __Payment__ c/a10V100000Kqx3jIAB"
        },
        "Id": "a10V100000Kqx3jIAB",
        "Name": "Payment-1048493",
        "s_c __Order_Id__ c": "801V100000nR3fEIAS",
        "Order_Number__c": "01825890",
        "Deposit_Account__c": "10302",
        "Cash_Sale__c": true,
        "Customer_Deposit__c": true,
        "s_c __Amount__ c": 479.25,
        "Order_Paid_In_Full__c": true,
        "Batch_ID__c": "1055493750"
      }
    }
  ]
}

```

```auto
function transform (options) {
  // Normalize: transform may get the full page (array) or a single record
  var input = options.record;
  
  var creditRecords = Array.isArray(input) ? input : [input];

  // Unwrap if fields are nested under a "record" property
  creditRecords = creditRecords.map(function (r) {
    return (r && r.record) ? r.record : r;
  });

  var DEBIT_ACCT = '703'; // hardcoded debit-side account
  var CREDIT_ACCT = '539';

  var lines = [];
  var ex = '';
  creditRecords.forEach(function (rec) {
    var amount = rec.TotalPrice;
    ex = rec.OrderId;
    // Shared dimensions for both sides of the pair
    var department = rec.Department__c; // confirm -> internalId
    var klass = rec.Service_Line__c; // confirm -> internalId
    var location = rec.Netsuite_Location_Id__c;

    // Credit line
    lines.push({
      linetype:'credit',
      credit: amount,
      debit: 0,
      account:CREDIT_ACCT,
      memo: 'Credit Line',
      department: department,
      class: klass,
      location: location,
      revrecstartdate: rec.Rev_Rec_Start_Date__c,
      revrecenddate: rec.Rev_Rec_End_Date__c,
      revrecrulename:"Rev Start/End Date"
      
    });

    // Debit line (mirror)
    lines.push({
      linetype:'debit',
      debit: amount,
      credit:0,
      account: DEBIT_ACCT,
      memo: 'Debit Line',
      department: department,
      class: klass,
      location: location,
      revrecenddate: '',
      revrecstartdate: '',
      revrecrulename:''
    });
  });

  // Build the JE header + nested lines
  return {
    externalId: ex, // TBD - derive from Order or a sequence
    subsidiary: '3',
    currency: '1',
    memo: 'Dummy JE for testing', // TBD
    approved: false,
    customform: '221',
    lines: lines
    // tranDate / postingPeriod omitted - you said they're auto-populated.
    // Add them here if you'd rather set them explicitly.
  };
}

```

The transformer i am using is abv and the NS mappings are below  
z

 ![image](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/3/32b2caaf538f7d94998511898d6bf7ba7e5ba340.png)

I keep getting errors from NS below which makes me think that the transformer is not working  
How can this be corrected ??

 ![image](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/1/1e4253d009b22815b95c3010215827645322c523.png)

---

<div class="post-metadata">

**Author:** ![alandepew](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/alandepew/32/7274_2.png) [@alandepew](https://connective.celigo.com/u/alandepew)\
**Post date:** [July 10, 2026, 4:18pm UTC](https://connective.celigo.com/t/how-to-create-a-je-in-ns-from-orderlines-from-sf/6380/2 "2026-07-10T16:18:33Z")

</div>

Can you share the errors from the "View response" tab? We are only seeing the retry data.

---

<div class="post-metadata">

**Author:** ![Anshul\_Gupta](https://sea1.discourse-cdn.com/flex001/user_avatar/connective.celigo.com/anshul_gupta/32/9539_2.png) [@Anshul\_Gupta](https://connective.celigo.com/u/Anshul_Gupta)\
**Post date:** [July 11, 2026, 9:19am UTC](https://connective.celigo.com/t/how-to-create-a-je-in-ns-from-orderlines-from-sf/6380/3 "2026-07-11T09:19:18Z")

</div>

Thanks for looking into this Alan !!  
The request to netsuite is below :

 ![image](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/b/b0c8c2a5218b1454420459259b94510f3480e715.png)  
The response is below:

 ![image](https://us1.discourse-cdn.com/flex001/uploads/celigo/original/2X/d/d75cc796eb3f1c156d4c2b9dfa81ac153d94911a.png)
