Solved

How to check if a variable is passed into a workflow?

  • 23 May 2023
  • 2 replies
  • 392 views

Userlevel 5
Badge +15

Hello,

 

I have encountered a pretty odd scenario. I have a workflow that automatically populates the market value when a customer order is newly created. There are two ways to create a customer order, either you create a new customer order from the customer order screen, or you create a customer order from a sales quotation. 

 

Sadly, I can only get one of these scenarios to work at a single time. I’ve created a custom event and action to handle when a customer order is created from a sales quotation. This event uses the variables from a table, which are formatted as ORDER_NO, CUSTOMER_NO, etc. The one issue with this, is that when I try to create a customer order from the customer order screen, I get an error saying 

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

This happens because the process to create a customer order on the customer order screen uses the variable ‘OrderNo’ not ‘ORDER_NO’. The same goes for if I modify the workflow and do the opposite and create a customer order from the Sales Quotation screen, I’d get the error

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

How can I parse the variables in IFS and use either the capitalized sql column names (SNAKE_CASE) or the (PascalCase) projection field names?

Do I need two workflows? How can I only run the correct workflow if I can’t even check if a field is null without the system throwing the same error?

 

Any and All advise would be greatly appreciated.

 

Thanks,
Bryan

icon

Best answer by Joel Taylor 24 May 2023, 00:57

View original

2 replies

Userlevel 1
Badge +2

Hi Bryan,

I’ve never done what you are trying but there is an example in 22R2 of something similar being done in InteractiveDisplaysDetach Workflow.

 

Perhaps using an if statement & two script blocks (For example if you want to always use ORDER_NO)

You would need to add lines in the script blocks for each variable that is different between the two ways the Workflow can be called.

Step 3 would be the block your code starts in now I believe. Or a block it could always start in.

1. In step 1 check for the variables such as “OrderNo”, use the javaScript if statement.

If it finds the pattern you don’t want then then go to step 2. Otherwise if doesn’t find that default to setp 3.

 

2. Use a JavaScript script block to change the value that causes the error. This would set a variable ORDER_NO

var OrderNo = null;
OrderNo = execution.getVariable("OrderNo");
execution.setVariable("ORDER_NO", OrderNo);

3. Where your code starts now

 

 

Another Possibility I haven’t tried

I think that you might be able to use a substitution variables on the event? 

Manage Event Actions - Technical Documentation For IFS Cloud

Userlevel 5
Badge +15

Hi @Joel Taylor 

Thank you so much, I really appreciate the answer. I had a similar idea on the drive to work this morning and your response solidifies it. 

I’ll try it and hopefully all goes well.

 

Thanks again,
Bryan

Reply