Create 

The Create logic block is used in the Integrate logic block to insert successfully integrated records into another table. To create this type of logic block for your integration table, you must create a new logic block with the following configurations: 

ActionType
Table Name
Security OptionUse NATE container
Create<table name>Background Task<table name>IntegrationPrivateFalse

Note: This logic block could also be Transaction type if a popup notification is needed.

In the Logic Builder, build your logic block according to the steps outlined below:

The requirements below cover if the records being integrated have an IntegrationAction of Create and will handle creation of the record in the system if one does not already exist.  Optionally, with the IntegrationAction of Create, the logic block can be coded in such a way that the table can be fetched and if the record is found, then an update to that record can occur.  The requirements below do not cover if the IntegrationAction of Update is passed in.  While this is a possible use case, this would require that ALL records being integrated are known to already exist in the system.

RequirementsPseudo-code
  • This logic block could vary between tables/modules and each one could be slightly different from one another depending upon your use case.
  • This logic block should set all values and perform any edits as needed.
    • Sometimes, depending on the specific table being integrated, field derivations are necessary prior to inserting a new record. Application exceptions might be thrown as a result of these derivations.
  • This will be a single record insert.
  • It does not fetch the integration table.
  • After the values of all fields are defined, the insert action into the destination table is taken.  Pass in the integration record being processed. Always pass the integration record in the Additional Mappings of the insert action or call logic block action (if using an action block). This will allow partner's extensions and customer's customized field to flow through the tables.
  • Trigger will be automatically run.
  • If ActionBlocks are used, a call to the Action Block is necessary.
  • NOTE: The action block (or table trigger) should allow for any auto number fields to be passed in via the integrations. If passed in, use it. This will make the integration more performant. It is limited to the data item type (text can accept alphanumeric), it does not matter if it's historical or non-historical, and it does not need to match the auto number format that is defined. 

Option 1:

// Perform all necessary field derivations.

// Should allow for any auto number fields to be passed in.

Insert <table name> with all field correctly mapped into destination table. //need to pass nwImportRunNumber, nwImportRowNumber, nwExternalId, and always pass the integration record in the Additional Mappings of the Insert action. 

// **If using table triggers the insert above will call the triggers

// **If using action block, you should perform a call to the Action Block instead of performing the Insert statement to the table directly. Pass the integration table to the Additional Mappings in the call logic block action.

Option 2: 

//Perform all necessary field derivations.

If IntegrationAction = Create and and the record being created doesn't already exist in the destination table 

// Should allow for any auto number fields to be passed in.

Insert <table name> with all field correctly mapped into destination table. //need to pass nwImportRunNumber, nwImportRowNumber, nwExternalId, and always pass the integration record in the Additional Mappings of the Insert action.

// **If using table triggers the insert above will call the triggers

// **If using action block, you should perform a call to the Action Block instead of performing the Insert statement to the table directly. Pass the integration table to the Additional Mappings in the call logic block action.

If IntegrationAction = Create and the record being created already exists in the destination table

Update <table name> with all fields correctly mapping into destination table. //need to pass nwImportRunNumber, nwImportRowNumber, and nwExternalId

// **If using table triggers the update above will call the triggers

// **If using action block, you should perform a call to the Action Block instead of performing the Insert statement to the table directly. 

Integrate 

The Integrate logic block is used in the Process Run list form action of the integration application to begin the integration process. To create this type of logic block for your integration table , you must create a new logic block with the following configurations: 

It is important to note, that while these standards are written to incorporate using the queue parallel processing action, we always need to think about table contention. Parallel processing can only work when there is no contention. If your process could be updating the same record on another table for multiple records that are being imported, you could have contention issues. This means there would be multiple threads that are spawned that are all trying to update the same record at the same time which will lock each other out or cause a time out. To eliminate this type of contention you can use a bucket in your parallel processing action. Define your bucket so that all rows that will update the same record will run sequentially in the same thread and ensure there is no contention. The order of processing records is not guaranteed.

Action
Type
Table Name
Security Option
Use NATE container
Integrate<table name>Background Task
<table name>IntegrationPublic-Secured
False

In the Logic Builder, build your logic block according to the steps outlined below:

RequirementsPseudo-code
  • If the Import Run Number field has no value, set CoreMsg89 to let the user know that an import run number is required.
  • Use the Queue Parallel Processingaction to run integration by Import Run Number and a New Integration Status, for distinct Group Levels
    • The Queue Parallel Processing action will call the "per record" logic block in update mode.  

If nwImportRunNumber is empty

True: Interrupt with Error - CoreMsg89

// Call Parallel Processor passing in Integration<table name> to process <table name> integrations

Queue Parallel Processing Action

Table: <table name>Integration

Expression: <table name>Integration.nwImportRunNumber = <table name>Integration.nwImportRunNumber AND <table name>Integration.IntegrationStatus = NEW

Per Records Logic Block: Process<table name>Group

Dynamically Mapped Record: True

Summary Inputs Logic Block: Integration<table name>Summary

Data Source Name: <table name>Integration

Distinct Fields: As needed

 Process Group

The Process Group logic block is used in the Integrate logic block and is used to process each group. This logic block calls the Create logic block and performs the error handling. To create this type of logic block for your integration table , you must create a new logic block with the following configurations:

Action
Type
Table Name
Security Option
Use NATE container
Process<table name>GroupBackground Task
<table name>IntegrationPrivateFalse

In the Logic Builder, build your logic according the steps outlined below:

RequirementsPseudo-code
  • Call the DeleteIntegrationsErrorLogMessagesByHeaderID logic block in a new database transaction to delete any existing error log records for Import Run Number

  • Call the Create<table name> logic block that logs messages into a message list

    • If errors exist in the message list

      • Loop through messages from Create<table name>

        • Fetch and Lock <table name>Integration by nwID

          • If data is found, insert integrations message/error to the IntegrationsErrorLog subtable, set the status on the integration record to Error and update fetched integration record.

    • If no error exists in the message list

      • Fetch and Lock <table name>Integration by nwID

        • If data is found, update integrations record status to Processed

// Delete any existing error log records for run number and group level, before processing        

Call DeleteIntegrationsErrorLogMessagesByHeaderID pass nwID of the <table name>Integration to the nwHeaderID of the Error table - New Trans Boundary = True 

// Call Create to process all records for group - should be in the same transaction boundary

Call Create<table name> - <table name>Integration DSN 

Set Message List Name = Create<table name>MessageList

If Create<table name>MessageList contains errors 

Loop through Create<table name>MessageList    

// Fetch integration record to update with message 

Fetch and Lock Integration by nwid <table name>Integration               

Data Found                                     

Set status = ERROR

Insert integrations message/error to subtable           

// Updates the integration record fetched

Update Record

Else                             

Fetch and Lock Integration by nwid 

Data Found                                       

Set status = Processed

Update Integration Record

Integration Summary 

The Integration Summary logic block is called by the Queue Parallel Processing action once all groups are processed in parallel. To create this type of logic block for your integration table , you must create a new logic block with the following configurations: 

Action
Type
Table Name
Security Option
Use NATE container
Integration<table name>SummaryBackground Task
<table name>IntegrationPrivateFalse

Note: This logic block could also be Transaction type if a popup notification is needed.

In the Logic Builder, build your logic according the steps outlined below:

RequirementsPseudo-code

  • Check if errors exist using the Aggregate logic block action on the import run number and the integration status of error in the integration table

    • If errors exist, give standard error message with the count of errors. We do not give the number of records processed as that can be found in the results of the processing parallel job.

  • If Purge Process is set to true,  call the Purge<table name> logic block as a parallel process

    • All "Processed" records should be purged even if other records are at "Errored". Only the Errored ones should be left in the integration table after the purge completes. 

  • NOTE: Purging of records should always be done in this logic block. We want to display the number of records processed and the number of records errored. We cannot acheive this, if we are purging as we process records. 


// Check if error exist

Aggregate nwImportRunNumber and Integration Status = Error from <table name>Integration

Data Found:

Set Errors from nwId_count

If Errors > 0

Create Message using CoreMsg87, Background Task Summary, Log with <table name>Integration, nwImportRunNumber, and Count of Errors

Else

If Purge Process is true

   Call QueueProcessing Action (Fetch where nwImportRunNumber = nwImportRunNumber and IntegrationStatus = Processed)

      Input Mapping - ParallelPurgeProcessed flag = true

      Per record logic block Purge<tablename>



Reset status

The Reset status logic block is used in the Reset Run Status list form action of the integration application to reset record statuses. To create this type of logic block for your integration table , you must create a new logic block with the following configurations: 

Action
Type
Table Name
Security Option
Use NATE container
Reset<table name>IntegrationStatusBackground Task
<table name>IntegrationPublic-SecuredFalse

In the Logic Builder, build your logic according the steps outlined below:

RequirementsPseudo-code
  • If the Import Run Number field does not have a value, set CoreMsg89 to let the user know an import run number is required.
  • If the Import Run Number field has a value, fetch and lock records from <table name>Integration by Import Run Number and an ERROR Integration Status. 
    • If data is found, set record to a NEW Integration Status and then update record. 

If nwImportRunNumber is empty

Set Message CoreMsg89

End If

// This will set records for a run, and optionally GroupLevel1, from ERROR to NEW

Fetch and Lock <hd table name>Integration by nwImportRunNumber, GroupLevel1 (mark as optional) and IntegrationStatus = ERROR

Data Found

Set Status = NEW

Update record

No Data

Refresh UI 

Purge 

The Purge logic block is used in the Purge Run list form action of the integration application to purge specific records from the integration table. To create this type of logic block for your integration table , you must create a new logic block with the following configurations:

Action
Type
Table Name
Security Option
Use NATE container
Purge<table name>Background Task
<table name>IntegrationPublic-Secured
False

In the Logic Builder, build your logic block according the steps outlined below:

RequirementsPseudo-code
  • If the Import Run Number field does not have a value, set CoreMsg89 to let the user know an import run number is required.
  • If the Import Run Number field has a value, fetch and lock records from the <table name>Integration table by the Import Run Number.
    • If data is found, delete records from the <table name>Integration table. 
    • If no data is found, set CoreMsg88 to let the user know that records with the selected run number were not found, were already processed, or a run number was not selected.

If nwImportRunNumber is empty

True

Set Message CoreMsg89

False

// Fetch and Lock by nwImportRunNumber

Fetch and Lock <table name>Integration by nwImportRunNumber

Data found

Delete all records from <table name>Integration

No Data

Set message CoreMsg88

End If