'Tabular Editor - Set "Shared Expression" value from Tabular Editor CLI (with Azure Devops)

I need to change the value of a parameter in a TOM. I am using Azure Devops with steps that include Tabular Editor CLI. I have written a one-line script that should be able to change the value of a Shared Expression. (Maybe a shared expression is read only?)

The script that will be executed

Model.Expressions["CustomerNameParameter"].Expression = "\"some value\" meta [IsParameterQuery=true, Type=\"Text\", IsParameterQueryRequired=true]";

I returns an error whenever Azure Devops tries to run it: enter image description here

It cannot find the CustomerNameParameter in the model.

My build looks like this:

Starting: Build Mode.bim from SourceDirectory
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.201.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents: shell
TabularEditor.exe "D:\a\1\s" -B "D:\a\1\a\Model.bim"
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\ba31b528-d9a3-42cc-9099-d80d46d1ffe6.cmd""

Tabular Editor 2.12.4 (build 2.12.7563.29301)
--------------------------------
Dependency tree built in 113 ms
Loading model...
Building Model.bim file...
Finishing: Build Mode.bim from SourceDirectory



Solution 1:[1]

Your script looks good. Have you tried executing it within the Tabular Editor UI?

enter image description here

Perhaps the parameter is named differently in your model. You can use the following script in the CLI to output the list of parameters:

foreach(var expr in Model.Expressions) Info(expr.Name);

The result when executed in the CLI on the model shown in the screenshot above:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dan