cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
gav24
Regular Visitor

Unable to set variable within Flow

Hey guys,

Having a bit of trouble setting a variable. Getting the following error:
Unable to process template language expressions in action 'Variable_to_store_title_value' inputs at line '1' and column '50651': 'The template language function 'if' expects three parameter: the condition to test as the first parameter, the value to return if the condition is true as the second parameter, and the value to return if the condition is false as the third parameter. The function was invoked with '2' parameter(s). Please see https://aka.ms/logicexpressions#if for usage details.'.

Variable and logic I use, note newWorkRequestNumber resolves to 0001 for all cases:

Name: titleValue
Type: String
Value:
@{if(equals(outputs('Get_response_details')?['body/rA'], 'Change Request'), concat('CR-', variables('newWorkRequestNumber'), ' ', outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Incident'), concat('INC-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Task'), concat('TSK-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX'])
))}

So I should always get either 'Change Request', 'Incident' or 'Task' for the conditional logic; which will created a new variable as CR-0001 TitleName. My logic seems to be working for Change Request and Incidents, but getting the above error for Tasks.

Any help would be appreciated.

6 REPLIES 6
JeffGimo
Resolver I
Resolver I

Can you also post a screenshot of your issue?

gav24
Regular Visitor

Hey Jeff, sure.

gav24_0-1628842305391.png

 

With the logic within the failed step (expression is above):

gav24_1-1628842442739.png


As mentioned, 'Change Request' and 'Incident' are working fine, but not 'Task'.

Can you try this expression instead.

@{if(equals(outputs('Get_response_details')?['body/rA'], 'Change Request'), concat('CR-', variables('newWorkRequestNumber'), ' ', outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Incident'), concat('INC-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Task'), concat('TSK-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX'])
)))}
gav24
Regular Visitor

Hey,

 

Tried the above but same error occurred.

Kind regards.

Try this one. 

@{if(equals(outputs('Get_response_details')?['body/rA'], 'Change Request'), concat('CR-', variables('newWorkRequestNumber'), ' ', outputs('Get_response_details')?['body/rX'])),
if(equals(outputs('Get_response_details')?['body/rA'], 'Incident'), concat('INC-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Task'), concat('TSK-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX'])
))}

 

 

If that doesn't work. Try to put each expression in an Compose and test it. You'll see what's wrong.

if(equals(outputs('Get_response_details')?['body/rA'], 'Task'), concat('TSK-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']))


if(equals(outputs('Get_response_details')?['body/rA'], 'Incident'), concat('INC-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']))


if(equals(outputs('Get_response_details')?['body/rA'], 'Change Request'), concat('CR-', variables('newWorkRequestNumber'), ' ', outputs('Get_response_details')?['body/rX']))

 

JeffGimo
Resolver I
Resolver I

I think you're missing another expression and a closing parenthesis.

Try this expression instead.

@{if(equals(outputs('Get_response_details')?['body/rA'], 'Change Request'), concat('CR-', variables('newWorkRequestNumber'), ' ', outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Incident'), concat('INC-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']),
if(equals(outputs('Get_response_details')?['body/rA'], 'Task'), concat('TSK-', variables('newWorkRequestNumber'), ' ' , outputs('Get_response_details')?['body/rX']), 'Missing Expression')))}

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,533)