Skip to main content
Community site session details

Community site session details

Session Id : VWX47LVpsrjllI5+8TgjhB
Power Automate - Building Flows
Unanswered

Unable to set variable within Flow

Like (0) ShareShare
ReportReport
Posted on 12 Aug 2021 13:40:37 by 4

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.

  • JeffGimo Profile Picture
    221 on 13 Aug 2021 at 13:41:36
    Re: Unable to set variable within Flow

    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')))}
  • JeffGimo Profile Picture
    221 on 13 Aug 2021 at 13:32:21
    Re: Unable to set variable within Flow

    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']))

     

  • gav24 Profile Picture
    4 on 13 Aug 2021 at 13:19:03
    Re: Unable to set variable within Flow

    Hey,

     

    Tried the above but same error occurred.

    Kind regards.

  • JeffGimo Profile Picture
    221 on 13 Aug 2021 at 13:13:49
    Re: Unable to set variable within Flow

    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 Profile Picture
    4 on 13 Aug 2021 at 08:14:58
    Re: Unable to set variable within Flow

    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'.

  • JeffGimo Profile Picture
    221 on 12 Aug 2021 at 15:24:47
    Re: Unable to set variable within Flow

    Can you also post a screenshot of your issue?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2