Solved

Assign Function in Report Designer

  • 8 October 2021
  • 5 replies
  • 391 views

Userlevel 5
Badge +2

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

https://help-2021r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=83fa0867-0eaa-4d93-9f9a-92c0f1b384d3

 

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?

icon

Best answer by gprice27 8 October 2021, 20:06

View original

5 replies

Badge

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 2
Badge

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)

 

cheers

 

 

Userlevel 5
Badge +2

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 4
Badge

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 5
Badge +2

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

Reply


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 — 2022  Acumatica, Inc. All rights reserved