Breadcrumbs

WRITEBACK

Overview

The WRITEBACK function sends one or more lines of values to the ERP.

The function uses the fields specified in a pre-defined Import Scenario for a specific screen in the ERP.

Syntax

=WRITEBACK(
    ConnectionName,
    ScreenSettings,
    ImportScenarioName,
    DataColumnNames,
    OutputRange,
    RangeOrDataItem,
    ...
)

Arguments

The WRITEBACK function uses the following arguments:

Argument

Required/Optional

Description

ConnectionName

Required

The name of the connection as configured in the Connection Manager

This function does not support the multiple connection functionality.

ScreenSettings

Required

The ScreenID of the ERP screen containing the data that is being sent to the ERP.

ImportScenarioName

Required

The name of the pre-defined Import Scenario that is being used to send data to the ERP.

DataColumnNames

Required

The names of the fields to which data will be written. Provide these names using one of two methods:

  1. A single row in the worksheet – uses default data types.

  2. A two-row array with values in the first row and data type specifiers (text / string or empty) in the second row. See the dedicated section for details.

OutputRange

Optional

An Excel range reference to a cell (or range of cells) for output arguments. If multiple records are expected, the range should include a row for each record.

RangeOrDataItem

Required

The first set of data to be sent to the ERP. The values to be written must be specified in the same order as the column/field names specified in the DataColumnNames argument

...




The ScreenID parameter can be specified either with or without dots.

e.g.,

image-20250822-111940.png

or

image-20250822-112053.png

Zeros in Writebacks with Velixo NX


In order for zero values to be sent to the ERP by Velixo NX, the zeros must either be contained within quotation marks ("0") or be a cell reference to a cell that contains the zero.

Defining the data type in DataColumnNames

Use this method in scenarios where the default behavior would treat values as numbers, and you explicitly want them treated as text, for example, values with trailing or leading zeros (1599.000 would be converted to 1599 by default, and 00123 would be converted to 123).

Use text or string in the second column for values that look numeric but must be treated as text.
Keep cells empty to use the default type assignment.

For example, in the following array, the CostCode column uses values like 610.229, 610.230, or 630.300. Since these values are treated as numbers by default, Excel will convert them to 610.229, 610.23, and 630.3 to eliminate trailing zeros, resulting in discrepancies and Writeback errors.

image-20260219-135140.png

This translates to {“TaskID”,”CostCode”,”InventoryID”,”AccountGroup”} in the DataColumnNames argument.

In order for the CostCode values to remain unchanged, declare the data type for the CostCode column as text or string in the second row of the array used in the DataColumnNames as follows:

image-20260219-135627.png

This translates to {“TaskID”,”CostCode”,”InventoryID”,”AccountGroup”;"","text","",""} in the DataColumnNames argument.

This addition will cause the values in the CostCode to be treated as text and prevent alterations. The data types for the remaining columns will remain default, as the remaining cells in the second row of the array are empty.

Example

Given this configuration:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/K41kUs33Nam3BMWnVxFv4Rodb1kb4rJ99Q.png


We could create this function:

=WRITEBACK(
    "Demo",
    "AR303000",
    "ACU Import Customers",
    B2:O2,
    B3:O3,
    B4:O4,
    B5:O5
)


Description
As a basic example, will be writing data to the screen with the ID "AR303000".

That ERP contains an active, pre-defined Import Scenario named ACU Import Customers:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/xEwSYe0dDYx9iN4cXPFr55H1qHW724YVow.png


To help us create our worksheet, we can use the WRITEBACKARGUMENTS function to list the name of the fields associated with that specific Import Scenario:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/37EiBtxhihug6z9z5C_7R2BGme72kgrstw.png


and then fill in the data we want to send to the specified ScreenID:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/_0nTr4MWmeWFphasC9ALOy5V9uBxCPE4iw.png

Empty values cannot be omitted if column names are specified for them in that WRITEBACK formula. The number of values must be equal to the number of column names. Otherwise, an error message will be shown:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/6MMf0ZP8UfewstKFxCaHbzqESruGnWzsdQ.png


Our WRITEBACK function

=WRITEBACK("Demo", "AR303000", "ACU Import Customers", B1:O1, B2:O2, B3:O3, B4:O4, B5:O5)

=WRITEBACK(
    "Demo",
    "AR303000",
    "ACU Import Customers",
    B1:O1,
    B2:O2,
    B3:O3,
    B4:O4,
    B5:O5
)


... can then reference the data we have filled in.

  • B1:O1 references the names of the fields to which we will be sending data

  • B2:O2 references the first line of data we are sending

  • B3:O3 references the second line of data we are sending.

  • etc.

The WRITEBACK function does not require us to use cell references; we could also type information directly into the function.

e.g.,

=WRITEBACK(
    "Demo",
    "AR303000",
    "ACU Import Customers",
    A4#,
    {
        "TESTDEL1", "First", "test@mail.com", "79169224455",
        "1-st Ave", "23 bul.2", "New York", "US", "NY",
        "", "LOCAL", "", "", ""
    }
)



The WRITEBACK function also supports importing multiple entries with a single function call. Expanding on the above example, we could send two records to the ERP like this:

=WRITEBACK(
    "Demo",
    "AR303000",
    "ACU Import Customers",
    {"Customer ID", "Customer Name", "Email", "Phone 1", "Address Line 1", "Address Line 2", "City", "Country Code", "State"},
    ,
    {"TESTDEL1", "First", "test@mail.com", "79169224455", "1-st Ave", "23 bul.2", "New York", "US", "NY"},
    {"TESTDEL2", "First", "test@mail.com", "79169224455", "1-st Ave", "23 bul.2", "New York", "US", "NY"}
)


We are sending data for both TESTDEL1 and TESTDEL2 with a single WRITEBACK function with each set of data contained within its own set of braces { }

See below for additional ways to compose writeback data.


Result

Before the data is sent to the ERP...

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/Gv9j9vt6wrjOwr-qtWzdln2vRRd5hC1Agw.png

...the status of the function is Pending:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/VDEQcKCUBIdFRVs5Nbmji3DAhnSjR7ZrSg.png


Once we select Import Current Worksheet, the process will start:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/Riw3tT4wjnzy6DKrzAq-eEIu3gWo53ghhA.png


Once the process is complete...

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/V5tj8vBdQGYsR6KEZE0S7RDPrS9h7pKlHg.png


... the status of the WRITEBACK function will change to Line range uploaded...

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/wXIUbrwAw1Pb6pP3hdV2B3cU8K4LMfLJVA.png


... and, within our ERP, we can visit screen AR303000 and see that the data has been imported:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/moDhCUgCcq3WVaaEVR4FFpjbrOV_Z1Qt2g.png


Ways to build writeback data lines

In this section, let's explore all the different ways how you can compose data for the WRITEBACK function. For your convenience, we made the function very powerful and flexible in that regard.

We will be using a hypothetical example where you write back data lines containing an account number, employee ID, a monetary amount, and a date. We'll be using a fictional screen id EX123456 and scenario names "EX Import Lines".

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/XCLGVsh7Q_Wl8ANPZpoUPG3C0x0oH6Iltw.png


As separate lines - multiple WRITEBACK functions

The first way to write back such a block of data would be to just specify every data line as separate RangeOrDataItem arguments of the WRITEBACK function:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/j09LDAOa2lJ1izpeT9GepBVx7xG4YVFqcQ.png

This works great if the number of lines doesn't change over time, or changes relatively infrequently.

The downside is that you need to keep track when the number of lines changes, and not forget to copy down the formula every now and then.

As separate lines - single WRITEBACK function

A slight variation of the above approach is if you want to use just one WRITEBACK function and display the status just once on your worksheet. To specify data items as separate lines in such a case, you can use multiple RangeOrDataItem arguments representing writeback lines:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/Oi8i83_A_GZnEzuZRMOOgHG9u-NN812rrw.png

The downside here, again, is when the number of items changes over time, you will need to manually modify your formula.

As a block of data - single WRITEBACK function

Alternatively, you can just put the whole Excel range into the first RangeOrDataItem argument of the WRITEBACK function:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/PMs-YoVJP9mW6p2sk5U9GZqSH_jqfz6QeA.png


With hard-coded range references, it might be an OK choice when the shape of data and the number of lines stays the same over time. If the shape of data changes, however, there is a risk that you might forget to modify the formula to include the additional data lines.


It is a great choice, though, when the whole block of data is a spilling range:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/liAmg5AJ8Ga_6uHChQJRIbKhg526g9sNvA.png


You can use such functions as COLLATE, HSTACK and VSTACK to compose such a dynamic block.

From separate columns of data - single WRITEBACK function

Let's suppose that the employee's name in our example stays the same, no matter what, and the date is the same for every line.

Also, let's suppose that the Account and Amount are Excel spill ranges coming from two different functions or data sources.

Can we compose our writeback data in a more dynamic way without using HSTACK / COLLATE, and also avoid repeating JOHNDOE over every line?

Yes, we can!

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/UxUg-piHe94frz4gOIUsrECMaIZiq4qc4g.png

Note how we reference the Account / Amount using the spilling range syntax with "#", and also specify "EmployeeName" and "Date" as a single-cell-reference.

Velixo will be smart enough to internally compose data lines that look like this, where constant single-cell references are internally "copied down" for every row (in bold below):

81000, JOHNDOE, 100, 01/01/2022,
81010, JOHNDOE, 200, 01/01/2022,
81020, JOHNDOE, 300, 01/01/2022 etc.

This saves space on the worksheet, gets rid of unnecessary duplication, and is also completely robust if the spilling ranges of accounts/amounts resize in the future.


In the last example, we still need to specify all relevant data column names in the WRITEBACK function call.

Considerations

Setting BatchSize for the Writeback

To avoid ERP timeouts on large writebacks and to improve responsiveness of the application, data is broken up in batches of 100 records. If you are processing large batches of writebacks and using screens with auto-numbered keys (e.g., Journal Transactions Batch Number, Invoice Number), you can adjust the batch size to ensure your data is not broken up in multiple records.

This is accomplished by specifying the batch size to be used for the specific Screen ID.

Example

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/Hr7UlqsFoxqcZOVbMKueiY_lWelOVWvZzg.png

In this example, the WRITEBACK function will send 100 rows at a time to the IN202500 screen


You may also decide to perform separate writebacks for the header and detail rows, retrieving the autonumber value and using it for the detail lines, thereby avoiding this problem altogether.

Cash Accounts and Restrict Visibility by Branch

Under default conditions, Universal Writeback does not work for a cash account if the Restrict Visibility by Branch checkbox has been selected (within the ERP) for that account.

If a writeback is attempted on such an account, an error will be returned:

https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/FayRtTMGDZkb7Feeww-OsT6XWeqve8SJ-Q.png


https://s3.ca-central-1.amazonaws.com/cdn.velixo.com/helpdesk/PTUsTeBtGMM-WwsdsUa9_CN-OTHjTDVHuA.png


To avoid this issue, the WritebackBranch argument can be added to the screen ID. This argument should only be used if, during writeback, you want to use some Account IDs that have "restrict visibility by branch" enabled, such as with Cash Accounts.

Example

=@WRITEBACK(
    $B$3,
    "AP304000;WritebackBranch=prodwhole",
    "ACU Import AP Cash Purchases",
    {
        "Type", "Reference Nbr.", "Date", "Post Period", "Description",
        "Vendor ID", "Location ID", "Cash Account", "Payment Ref.", "Branch",
        "Line Branch", "Inventory ID (non-stock)", "Line Description", "Quantity",
        "Unit Cost", "Ext. Cost", "Account", "Subaccount"
    },
    ,
    [@Type],
    [@[Reference Nbr.]],
    [@Date],
    [@[Post Period]],
    [@Description],
    [@[Vendor ID]],
    [@[Location ID]],
    [@[Cash Account]],
    [@[Payment Ref.]],
    [@Branch],
    [@[Line Branch]],
    [@[Inventory ID (non-stock)]],
    [@[Line Description]],
    [@Quantity],
    [@[Unit Cost]],
    [@[Ext. Cost]],
    [@Account],
    [@Subaccount]
)