How to get sum of item already added in queue

I have a question. I have an excel file with headers Product_ID, Product_Name, Quantity. We have 10 products. I created a RE Framework, Read Excel and Add Bulk Queue Items. Now I have to fetch the total(sum) of Quantity. In Process, assigned Quantity as in_TransactionItem.SpecificContent(“Quantity”).ToString. and used For Each but not getting the sum of Quantity. Please help

How is Quantity formatted in the queue? Can you show some examples?

Ok, in that case, to get the sum, follow the following steps.

1.) Define a global variable MySum of type System.Double with default value 0 in your project.
2.) In your For Each loop, assign MySum to MySum + CDbl(in_TransactionItem.SpecificContent(“Quantity”)).

After the loop has completed, MySum will contain the total.

2 Likes

How to implement loop for it. For Each. “item” in “in_TransactionItems.ToString” , but its not working. Then I tried For Each “item” in “Quantity”, then its calculating quantity 3 times.

My mistake. Put the code outside of the For Each loop and remove the For Each activity.

Ok. I did that change, but now its giving the new value of Quantity, not SUM.

@Priyanka_Bauddha Are you using Get Transaction Item Activity ? Can you explain the Process flow what you are doing ? Is the Whole Process only to calculate the Sum of Quantity or are there other operations you need to perform?

I am using RE Framework. In Init : Read Range activity>Adding the items in Queue.
The Process flow is only to calculate sum of the Quantity.

@Priyanka_Bauddha By default the RE Framework template uses the Queue Item as the Transaction Item. Keeping that in mind I would say you would need to the following changes.

  1. Declare a Global variable, say TotalQuantity. Go to Main, then Create a Variable with type as Double, Scope as General Business Process. Initialise the value to 0.

  2. Go to Process Workflow. Comment All the Activities that you have used. Create an Argument called io_QuantitySum. Provide the direction as In/Out. Provide the type as Double. Save the Workflow.

  3. In the Process Workflow, considering the in_TransactionItem is already present and is of the type QueueItem. Use the below Expression in an Assign Activity.

io_QuantitySum = io_QuantitySum+CDbl(in_TransactionItem(“Quantity”).ToString)

  1. Use a Message Box with a Value io_QuantitySum variable to check the value.

  2. Got to Process State where the Process Workflow is Invoked. Click on Import Arguments, Provide the TotalQuantity variable to io_QuantitySum argument.

Let me know if you get any error while performing these Steps.

Also a Screenshot of Get Transaction Data Workflow and the Screenshots of the arguments in Process Workflow would help to get a better understanding of the Workflow, if the Steps don’t work.

2 Likes

Hi,

I executed it as you said, but getting error while fetching data from queue.

Also attaching the adding Queue snapshot.

No changes in Get Transactional Data.

@Priyanka_Bauddha That error means that the key that you are using is not present in the Queue, Can you Send a Screenshot of the Queue Transaction as well as What you have used in the Assign Statement?

I worked for that. Its working now. Its adding all items in the queue but giving sum of two items only

@Priyanka_Bauddha Refer this video you will get clear idea about it :

Regards,
Vrushali

@Vrushali_Gave Other use cases are working fine in RE Framework. but getting issue with the summation of queueitem.

@Priyanka_Bauddha Is it possible to provide your Whole workflow ?

@supermanPunch
Here its is:
sum of queue.zip (1.0 MB)

@Priyanka_Bauddha In the Process workflow, Just Remove the Get Transaction Item Activity and check.

It worked. Thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.