Inserting same records again and again into queue to process

Hi All

We have a process where our BOT receives an email from Outlook which has an order#. It fetches some parameters from email and inserts a record in the queue. Then in the process state we fetch that record from the queue and check whether we have received an acknowledgement of that email. If yes, we mark Acknowledged else mark Pending in the output parameter. We do this till the time we receive an acknowledgement of that email.

My question is instead of entering the same record everytime can we enter it only once and be there in the queue till it gets acknowledgement ?

@Palaniyappan @supermanPunch @rahulsharma @lakshman

Could you please help me here ?

2 Likes

Hi @kkpatel ,

I think you should use Postpone status for such items instead of Completed.
Do you use ReFramework for that?
What do you do with items at the end when the acknowledgment was not provided yet?
Output parameters are set for information purposes. I would suggest postponing the item and setting TransactionItem.Progress to Pending.

Regards,
Kamil

Yes we are using REF. What we are doing is using Get Transaction Data we are fetching each item from queue and then checking if any response is received. So in order to fetch the item from queue it has to be in New state in queue.

Thats why everytime we have to insert the item to the queue till the response of the email is received.

Yup, so you can Postpone the item and set the time in which the item will be available again to whatever you want. You can postpone the item and set the time like even a few minutes so that after a few minutes this item will available for Get transation data again.
Let me know if you need more help or assistant with that.

Regards,
Kamil

Ok

Usually what happens from Get Transaction Data it gets an item and makes it In Progress. So what I understand is if the response is not received for that email (in Process state) we are using Postpone Transaction Item activity and postpone for sometime.

In that case wont it go to Set Transaction status and make the transaction item status as Success ? Also will it available in the queue itself in New state ?

You’ll have to set a condition for postpone, of the transaction is postponed then that will not go in the set transaction flow, this can be done using a Boolean variable for checking if the current transaction is postponed or not

Yes, it’ll be in the New state

And once the postpone time threshold is reached, it’ll be picked by the performer.

Fine

Let’s try to play around with queue items

To reiterate again, Once after fetching the mail and it’s details you will be adding it to queue
Fetch that queue again and see for acknowledgment and if yes then change the status as SUCCESS or leave it as it is in IN PROGRESS status

Now the solution I would suggest is to add a unique value for REFERENCE with each queue item

Say for example along each mail if there is any specific unique value then mention that in reference
Make sure even after acknowledging that value in mail is not getting changed
And if you try to add the same value again with add queue item it will throw error
We can handle that with try catch block

So the steps involved are as follows

  1. First create a queue with Unique reference enabled in it and add queue item from studio with a reference
    image

  2. Then fetch the data back and validate

  3. If yes then mark the status as SUCCES

  4. If not leave it as it is in IN PROGRESS status

  5. Now once after a while when the bot is executed again and if we are trying to get an acknowledgment for a mail now
    While trying to add such item again it will obviously throw error

So surround that add queue item with a TRY CATCH Block so that it won’t throw any error and goes for the next item

That’s it

And

There is one more scenario if there is no such unique values in your queue item
Then we need to have a track of the queue items added to the queue
That is before adding to queue it has to be fed to a a excel file and one more last column as Status like a track sheet

every time when updating the status of a transaction then update here in the excel as well

So that when adding next to the queue you can check with the excel whether it already exists and what is the status of it

This would avoid you adding already existing queue item and also which is yet get processed

Hope this would help you

Cheers @kkpatel

Hi,

As @rahulsharma said, once the Item is postponed it has New status so that we cannot set transaction status in Reframework, because it will throw an error.:

The new item in the Queue will look more or less like this one:

The easiest way in my opinion is to set Transaction.Status = “New” (or simple boolean as rahulsharma suggested) after postponing and then use it to omit Set status part.

In that solution you will keep ‘alive’ all the items that have not got acknowledgement yet. You can extend this solution by adding the Deadline to the postponed items so that they will be marked as expired and will not stay as New forever.

It depends how you proceed with the items with no acknowledgement? Do you wait for next emails for them ? If so, you can add to the Get Transaction Item activity one more input - Reference to get the correct existing item from the Queue but here you will need to have Unique reference enabled as @Palaniyappan mentioned in his solution :wink:

I you resolved the issue with one of our propositions mark it as the solution :wink:

Best Regards,
Kamil

If we leave the transaction item in In Progress state how will it be picked again and what will happen to the item ? It will be Abandoned after sometime. So there is no future of the In Progress item right ? How will it be picked again to check the acknowledgement ?

Yes this approach will solve the issue.

But few concerns I want to raise here.

  1. Actually all the items in the queue are reflected in the Insights dashboard.

  2. So at the very first time one email will enter into the queue. In the Process state it will check for its acknowledgement email (if any) received (Response from the supplier of the order).

  3. If not yet received the output parameter of the transaction item will be marked as Pending.

  4. In that case we have to use the Postpone activity so that next time it will again check if response is received.

  5. But if we simply postpone it wont be shown in the Insight as its in New state.

  6. If we want to show in the Insight we have to make it Success using Set Transaction Status for the first time only and for the rest of the times we have postpone till response is received.

  7. Let say after some time it got acknowledged then we will mark the output parameter of the transaction item as Acknowledged and transaction status as Success.

  8. So in that case there will be two entries of the item in the queue as well as Insight. One is Pending, the first time what we set and another is Acknowledged, after acknowledgement.

So is there any solution for that it will have only one record ? If the Pending one we remove then it wont show in the Insights dashboard that this is Pending for acknowledgement which will impact the reporting.

Hi @kkpatel ,

Hope you had a great weekend :wink:

Lets summarize the issue. You want to have only one record per order but the problem is that once some of them are postponed they are not visible in the Insight right?
The second issue is that after getting acknowledgement each order will have two Items in the report?
I will do some research and will let you know my ideas. One think that comes to my mind is to create second Queue like ‘child queue’. In the first queue you can keep the origin items and in the second queue you can keep the items that are New and waiting for the acknowledgment. Once the acknowledgment is received you can mark the second item as completed/acknowledged. The problem here is that once you set transaction status in the first queue as completed and output data as pending it will not be possible to change it later on.
Do you think it could work for you?
If not, it might be worth to consider creating the reports itself instead of using Insight?

Regards,
Kamil