Solved

How to do error handling in workflows


Userlevel 5
Badge +15

Hello,

I currently have a workflow that takes the sale amount of a customer order line and places that value in the customsvalue field automatically. We do this because customsvalue is the only field with prices that moves over to shipment proforma invoice. 

I am fully aware that IFS wants the order taker to define this field manually, but it is a requirement that we handle this automatically. 

The workflow that we currently have works fine, as it goes off of the event when a customer order line is created, but the only issue is when a sales quotation is converted to a customer order. I get the error message 

“Error occurred while processing the request: Unknown property used in expression, ${LineItemNo} Cause: Cannot resolve Identifier ‘LineItemNo’”

How do I get around this issue so even the customer orders that are created from sales quotations work, and their customsvalue field gets populated?
 

Any and all advise would be greatly appreciated

Thanks,
Bryan

icon

Best answer by eqbstal 20 April 2023, 15:34

View original

17 replies

Userlevel 5
Badge +15

Some additional information:

 

This is the setup for the event action

 

This is the setup for the event 

 

And this is the setup for the workflow
 

 

Userlevel 7
Badge +21

Maybe that the LineItemNo is only prepared during insert, so it's not yet available when CO is generated from SalesQuotation.

What if you build in a check if LineItemNo is avaiable and if not use a counter to generate it? The counter could be in a loop until no more Quotation lines to read.

Userlevel 5
Badge +15

Hi @eqbstal 

 

Thank you for the reply, I was considering doing that, but I’m not 100% sure how to handle a list of those lines. Are those values stored in an array or an object? If I’m not mistaken, workflows use Java objects while they have executions and commands that use javascript. Javascript has objects, not arrays, and Java has both. 

I’m going to assume it would be a javascript object, that is set up to act like an array, but is there a location in documentation where I can read more about their setup? I’ve been sort of assuming a bunch and testing what works/doesnt work based off of some examples I’ve been given.

Also concerning me generating a value for LineItemNo, do LineItemNo’s start at 0 or 1? I will attempt to try this and update you on the results.

As always, thank you for the reply, I appreciate it immensely,
Bryan 

Userlevel 7
Badge +21

Found some base material for loop functionality. Is the following helpful:

Business Process Modeling - Technical Documentation For IFS Cloud

Userlevel 5
Badge +15

hi @eqbstal 

Perfect, thank you for the documentation. I appreciate it.
 

-Bryan

Userlevel 5
Badge +15

Hi @eqbstal 

I have a quick question about workflows if you don't mind (I tried to directly message you but for some reason, the message wouldnt send, so I’m asking it here). I checked the document you sent me, but it didnt seem to mention lists.

I have a projection task call this function "GetFileExtList(DocType):String" but I am not sure how to format it to handle the output. This is what my workflow looks like.

In that "get document list" section, I am calling that function. I want to read from that but how do I recognize the output in my script function inside the loop?

Any input would be appreciated.

 

Thanks,

Bryan

Userlevel 7
Badge +21

Hi @bdoucette 

Please include the workflow image.

I'm unaware of any GetFileExtList situations, so you have to give a lot of details to understand the question and/or what you try to achieve.

Userlevel 5
Badge +15

Hi @eqbstal 

Sorry about that, I attached the image to the message but I guess it didn’t load correctly.

 

 

Thanks,
Bryan

Userlevel 7
Badge +21

@bdoucette While looking at the workflow image, I saw there is no ‘identifier’ icon at the bottom of the sub process.

Select it and use the wrench to select the, I call it the hamburger, icon. Once selecting it, it will loop though the data as you started it with in the task that is before the sub process.

The Collection in your example will contain: GetFileExtList

Data is just a variable name for an array that will contain all the data found. Best to use Inspect to see what happens.

https://docs.ifs.com/techdocs/22r1/040_tailoring/500_business_process_automation/040_workflow_tooling/#troubleshoot_a_workflow_with_user_forms might give a hint on what the Element Variable data may contain (in the mentioned URL the Element Variable is Collection).

Userlevel 5
Badge +15

Hi @eqbstal sorry about that, the image I uploaded before was an outdated workflow I created. I have functional workflows that handle collections. That list I was grabbing wasn’t the best list to work with either, as the proper projection call should be ‘DocReferenceObjectSet’ from the projection ‘DocumentObjectConnectionsHandling’ with the parameters for keyref.

 

This is what my more recent workflow looks like 

 

Sadly, you cannot invoke Aurena agent calls via a workflow, so I could not print these attachments out, so I ended up creating a different workflow that displays a user task to prompt the user to print off the documents attached to this shipment/customer order.

 

Thank you for your input though!

Userlevel 7
Badge +21

@bdoucette I noticed the Script Task 'Prepare condition for gateway’.

Are you ok with sharing what the script looks like as I'm struggling with looping thru a subset as I want to have the status of the lowest approval step that is not Approved/Rejected.

I tried the use of a subset, but didn't get the loop to work. When there is no value for a field, the field is not there at all, so only available values are considered in the loop. In my loop I need the first step (out of the attached approval steps) that is not yet either Approved or Rejected.

No problem if you share it via a private message.

Userlevel 5
Badge +15

Hi @eqbstal

 

Of course, I’m happy to help.

Before that task, for the “Get attached document list” task, I am using a read projection task on the Projection “DocumentObjectConnectionsHandling” and the entityset “DocReferenceObjectSet” while setting the “read collection - Collection variable name” as DocReferenceObjectSet_Set (Bad naming convention)

For that “Prepare condition for gateway” script task, I’m using JavaScript. The code is this

var documentList = execution.getVariable('DocReferenceObjectSet_Set');
var documentsRemaining = false;

if(documentList && documentList.length > 0)
{
  documentsRemaining= true;
}

execution.setVariable('documentsRemaining', documentsRemaining);

 

Then for the arrow of “Are there more documents to loop through” I have a default arrow pointing to the end for “no” and the “yes” arrow is another javascript bit. Here’s the code for that

execution.getVariable('documentsRemaining') == true

lastly, just define the collection in the subProcess, and define the element, in this case I set this to “document” but truth be told, I’m not entirely sure if that element variable matters too much in my case, as I’m not using it.

If you need help with anything else, please feel free to ask. I’m not the most experienced with workflows, but I’m definitely getting better at creating them.

 

Thanks,
Bryan

Userlevel 7
Badge +21

@bdoucette I think I owe you one (or more). This works very good in my situation (working on automatic generation of approval steps based upon DocMan approval template).

Thank you so much,

Steve

Userlevel 5
Badge +15

@eqbstal I’m glad you found that helpful! Good luck in future development.

My pleasure,

Bryan

Userlevel 5
Badge +15

Hi @eqbstal,

I’m going to try to cash in that favor haha. Would you happen to know how to send an email via a workflow? I see some projection calls that deal with emails but none that I can trigger without the aurena agent/ in workflows.

Thanks,
Bryan

Userlevel 7
Badge +21

@bdoucette I have only environments to my availability that have either no mail server connected or it has been turned down as the environments are Dev/Test only. More to the point: never had a request to do that, so can't help you now.

Userlevel 5
Badge +15

Hi @eqbstal 

I see, well thanks for your quick reply anyways. I appreciate it nevertheless.

Reply