Set in_Arg default value based on Asset

Hello,
Is it possible to set a in_Argument default value based on Asset ? So when i call the workflow with null arg it takes the Asset value.
When i put a variable in default input from data manager it returns :

workflow.xaml: CS0103: The name ‘assetName’ does not exist in the current context

Hi @simon.l,

Refer below thread on an idea around how to achieve the same.

Regards
Sonali

Hello Sonali and thankyou for your response.

On the Datamanager i can’t set default value with a Variable, i get an error as i said in the question.

I’ve found a solution with assign activity inspired by this topic :

assetVar = "Tomato"

in_Arg = "Apple"

Then within the assign activity i use isNullOrEmpty method

finalValue = string.IsNullOrEmpty(in_Arg) ? assetVar : in_Arg

So when i call the workflow with a null inArg it returns the Tomato

1 Like

Hey @simon.l
You can’t use an Asset directly as a default value for an argument because the default field can’t run activities like Get Asset. That’s why you get the error - this logic only works at runtime.

The approach you shared with an Assign and string.IsNullOrEmpty() is the right way to go. It allows you to fall back to the Asset value if no argument is passed, which is exactly what you’re trying to achieve.

You can use this expression - This way, if in_Arg is null or empty, the fallback value from assetVar will be used instead.
If(String.IsNullOrEmpty(in_Arg), assetVar, in_Arg)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.