Salesforce

How Can I Count How Many Iterations Occurred on a Source? (Magic xpi 4.7)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Can I Count How Many Iterations Occurred on a Source? (Magic xpi 4.7)

When you work with Magic xpi’s Data Mapper, you might have situations where you need to know how many Source records you have. You might also want to define a different value in a certain field for every x number of records, or you might have a flat file Source where every x number of records are header lines and the remainder of the lines are related to those specific headers.

Magic xpi lets you count these Source records easily.

This topic assumes that you have already built and are working with a project containing a Data Mapper.

Counting the number of iterations that occurred on a Source:

After you have opened the project where you want to count the Source iterations, you should follow these steps:

  1. Under the relevant flow, double-click Flow Variables to open the Flow Variables repository.

  2. Click Add and create a new flow variable called F.counter. Set the variable’s type as Numeric.

  1. Double-click (or right-click and select Configuration) on the Data Mapper whose Source iterations you want to count to open the Data Mapper window.

  2. In the Data Mapper window, right-click on the parent compound node in the Destination pane and select Show Properties.

  3. In the Properties pane's Multi Updates parameter, click to open the Multi Updates dialog box. Here, click Add to create a new line.

  4. In the Variable Name column, click and select your F.counter variable.

  1. In the Expression column, click and enter the following expression: F.counter +1

This means that for each iteration a value of 1 is added to the F.counter variable, which starts from 0.

This iteration count takes place before any condition that you may have defined on the Destination node is executed. If you defined a false condition on the Destination node, you will receive the number of mapping attempts instead. To avoid this happening, and to obtain a true iteration count, you should define the same condition in the node's Properties pane’s Condition column as well.

  1. Click Save.

  2. Set a breakpoint, and then debug the flow by right-clicking on the flow in the Solution Explorer and selecting Debug.

  3. Run your project by clicking the Run/Continue Project button on the toolbar.

  4. Click the Context View button on the toolbar to open the Context View window.

  5. In the Context View window’s Flow Variable tab, you will see a value in the F.counter variable row’s Value column. This value is the number of iterations that occurred on your Source.

Reference
Attachment 
Attachment