AYETY
AYETY

Reputation: 710

Select statement string in form method in Dynamics AX 2012 r2

There is a code in Form's init method:

strQuery = strFmt("select * from %1", something);

And it gives BP warning that Method contains text constant: select * from %1

Should I create a label from it or should I define a local macro? Which is more advised?

Also is it ok on forms this kind of select statements?

Thanks.

Upvotes: 1

Views: 1242

Answers (2)

Geoffrey DELMEE
Geoffrey DELMEE

Reputation: 782

If you really need to manipulate queries in forms, don't do things like that. You can catch the query of the form datasource and alter it (add some ranges for example). Then in AX 2012, the best would be to put it in an interaction class.

Upvotes: 3

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

You should use single quotes. SQL statements should not be stored in labels.

And no, it is not okay, direct SQL in forms is a very bad idea.

If you have to access external databases with direct SQL, make a class to provide the data.

Upvotes: 3

Related Questions