In Designer mode

The first thing you need to do is modify the modules of all the objects that are involved in exchanges (these objects include documents, catalogs, and charts of characteristic types).

After the changes document numbers, catalog codes, and chart of accounts codes will be generated based on the value of the NumberingPrefix constant to ensure that such numbers and codes are unique.

Let us keep the function that generates the numbering prefix in a common module because in the future you might need to change the algorithm used to generate document prefixes.

  1. Add a common module named Exchange.
  2. Add the function shown in listing 24.1 to the module.

    Listing 24.1. Function that generates a number prefix

    Function GetNumberingPrefix() Export
        Return Constants.NumberingPrefix.Get();
    EndFunction
    As you can see, the function merely returns the value of the NumberingPrefix constant.

    Now let us update the Customers catalog.
  3. In the configuration object tree, right-click the Customers catalog and then click Open object module.
  4. Add the OnSetNewCode event handler as shown in listing 24.2.

    Listing 24.2. OnSetNewCode event handler

    Procedure OnSetNewCode(StandardProcessing, Prefix)
        Prefix = Exchange.GetNumberingPrefix();
    EndProcedure
    The OnSetNewCode event occurs when a new code is set for a catalog item. Note that you are creating this script in the object module instead of the form module because this event occurs for the object in general instead of some particular form.

    Prefix is the second parameter passed to the handler. A prefix is populated in this procedure, and the platform generates a code based on the prefix.

    The event handler calls a function of a common module. Since the module is not global, you address the function using the module name and the function name: Exchange.GetNumberingPrefix. In this procedure you assign the value of the NumberingPrefix constant to the prefix.
  5. Add similar handlers to all the catalogs and charts of characteristic types involved in exchanges:

    Catalogs:
    • Employees
    • MaterialsAndServices
    • Warehouses
    • MaterialOptions
    • AdditionalMaterialProperties
    Chart of characteristic types:
    • MaterialProperties
  6. For all these objects and for the Customers catalog, in the configuration object property palette increase code length to 11 characters.

    Now let us update the documents.
  7. In the GoodsReceipt document module, add the OnSetNewNumber event handler as shown in listing 24.3.

    Listing 24.3. OnSetNewNumber event handler

    Procedure OnSetNewNumber(StandardProcessing, Prefix)
        Prefix = Exchange.GetNumberingPrefix();
    EndProcedure
  8. Add similar handlers to all the documents involved in exchanges (in your configuration it is only the Services document).
  9. For both documents, in the configuration object property palette increase the number length to 11 characters.

    This completes the preparations for existing configuration objects, and you can move on to the development of data exchange procedures.
Next page: Adding an exchange plan
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.