Assign Function in Report Designer

  • 8 October 2021
  • 5 replies

Userlevel 6
Badge +1

I have some questions about the Assign function in Report Designer. You can see the documentation here, also pictured below:


My questions:

1. Is there a way to use Assign in a TextBox and return a result at the same time? I tried using a semicolon like this, but it didn’t work:

=Assign('$MyVariable','some value');
'Here is My Variable: '+$MyVariable

2. In the Help pictured above, what is <nowiki> doing?


Best answer by gprice27 8 October 2021, 20:06

View original

5 replies

Badge +11

Are you trying to return the variable or some other value? In my experience, the textbox will display the variable value and you actually have to hide it if you don’t want that.


According to Wiki Markup Reference, <nowiki> is supposed to ignore wiki markup

Userlevel 3

Hey Tim - It looks like if you use the Assign function with the 3rd parameter (resetExpression) that the calling variable takes on the value returned by the ‘expression’ as well.

Not sure of a specific use case for the resetExpression - but if you just set it to ‘False’ it should be enough to get it to work. I suspect you could use this so that the target variable becomes an accumulator - while the source variable is reset on some change in the state of data..or another Variable value.

To get this to work - I suspect you have to use a ‘calling variable’ in the textbox value parameter formula, instead of using the Assign expression in the value parameter of the textbox.

Its sort of chicken/egg scenario - so you may was well just reference the ‘target’ variable in the textbox value formula and prepend the text eg =Concat(‘Here is my Variable: ’, $MyVariable)

Hope that make some sort of sense…

I think the <nowiki> is just a tag that should not be visible in the text…. (cut and paste issue)





Userlevel 6
Badge +1

Thanks @Deetz and @gprice27 for your comments. Much appreciated. I was hoping to be able to define and use variables in the same expression window like you can do with DAX in Power BI, but that doesn’t seem to be the way that Assign works.

Userlevel 5
Badge +1

Not sure if you ever received an answer to this but I just came across your question while trying to do exactly the same thing you are talking about. I was also looking for a way to set a variable and then use it in a rather long nested IIf statement.

This seems to work:

=IIf(Assign('$MyVariable','some value') <> 'BANANA', '', 0) +
'Here is My Variable: ' + [$MyVariable]

It fails to validate when I click the button but gives the desired result. I think you could put whatever you like in the IIf bit as long as it doesn’t match the thing you are assigning.

Userlevel 6
Badge +1

Thanks @ppowell for sharing! I will definitely try your solution.


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved