AX 2009: Report Range on enums parsing enum value commas? - axapta

I think I may have found an interesting bug with AX 2009, and I'm unsure of how I can proceed.
I am attempting to write a new report, and one of the conditions of this report is to be filtered based on the Posting field of the LedgerTrans table. However, it seems that when the report goes to execute, the label of the enum Purchase, receipt is parsed without regard to the quotes. This normally wouldn't be a problem, but the enum label in this case contains a comma. The result is that when run the query dialog box reads: Purchase, consumption, __ILLEGAL_VALUE__. I get this result even if I use the enum value or name. The report must be left interactive, but this field must be locked, so we cannot get the users to adjust the query at run time.
At this point I don't want to change the label itself, but if it is the only way to solve this I will. Has anyone else run into this, or know how we could overcome it?

I've run into this before. Sometimes an acceptable option is hard-coding the conditional values as an OR statement, rather than the comma separated list:
((LedgerTrans.Posting == LedgerPostingType::PurchReceipt) || (LedgerTrans.Posting == LedgerPostingType::PurchConsump))
That can be typed into a range filter box, or can be set as the value of a range via x++ code:
ledgerPostingRange.value("((LedgerTrans.Posting == LedgerPostingType::PurchReceipt) ||
(LedgerTrans.Posting == LedgerPostingType::PurchConsump))");
AX doesn't try to convert these to the labels, so they stay as distinct values, instead of being rendered as labels. Note that parentheses are required for it to be parsed properly.
Since the ILLEGAL_VALUE can appear even when attempting to use a single value that contains a comma in its label, the same can be done for a single :
ledgerPostingRange.value("(LedgerTrans.Posting == LedgerPostingType::PurchReceipt)");

I would definitely change the label! But as a workaround you could use the enum value's number instead.
If the field is often queried, you could put the field in a dialog then change the query:
ledgerPostingRange.value(ledgerPostingType ? int2str(ledgerPostingType) : '');

Related

How to validate against item master table

I am creating a custom report screen in which I have a fields item number, item type, prod line and status and there is a condition for item number that is I have to validate it against pt_mstr which from what i understand means that the item number that I enter should be present in pt_mstr. And if it's blank then give an error. I've done the validation for blank with this code
If lvc_part = "" then do:
{us/bbi/pxmsg.i &msgnum=40 &errorlevel=3}
Undo mainloop, retry mainloop.
End.
Lvc_part is the variable i declared for item number and mainloop is the loop inside which I'm writing my entire logic. I am getting the general idea for validating item number against pt_mstr but I'm not getting how to put it down as a code. I'm thinking we need to include a find first query to see if the item number is present in pt_mstr or not but I'm not sure. Any leads would be helpful, if you want to know anything regarding the declarations I've used or anything else let me know. Thanks in advance!
You need to add code like this
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname> = lvc_part) THEN
<display error message>
or when it's a index with multiple fields:
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname1> = lvc_part
AND pt_mstr.<keyfieldname2> = <value>) THEN
<display error message>
Most likely you can (and should) leave out the FIRST phrase in the CAN-FIND expression as typically you'd be using a UNIQUE find here.

Display label based on, field on one data-source (singular) being within another data-source fields many

I am still learning, and looking for help on how to display a label based on one data-sources field value, being within another data-sources field value list.
I have one calculated table, displaying rows of documents within a folder, and wish to use a field representing the document number in that data-source, so that if it's ANYWHERE within another tables field it displays my label.
I've been trying to use projection as I think this is how to achieve it.
I can get it working based on both the current #datasouce.item.fieldnames but need it to base the calculation on all possible numbers in that tables field (Image below should make it easier to understand).
I expect that it has something to do with projections, but can't find anything within the learning templates or anywhere else to resolve the issue.
I think the following should work for you. For the 'Reserved' label have the following binding for the text property:
(#datasources.project_quotes.items..quotenumber).indexOf(#widget.datasource.item.Qnumber) !== -1 ? 'Reserved' : ''
I would suggest alternatively just to include a field in your calculated datasource and making the determination in your server script.

How to skip inserting value to Dynamics in Logic App with condition

I have many date values in CSV which is sent to logic app. In example:
date1;date2;date3;date4;date5;date6;date7
2011-12-30;2011-12-30;2011-12-30;2011-12-30;2011-12-30;2011-12-30;2011-12-30
2011-12-30;;2011-12-30;2011-12-30;2011-12-30;2011-12-30;2011-12-30
It is possible that there is empty date in the CSV. I need to insert those dates to Dynamics 365. As I insert those values if I insert the empty date it goes as "", which returns an error: "Cannot convert the literal '' to the expected type 'Edm.DateTimeOffset'.". Same happens if I try to pass null when date2 is empty ("").
Is there way to skip inserting anything with logic app? Or is there some other solution to this?
Most likely, you will need to stop sending CRM empty fields.
However, you're transforming the data from the CSV shape to the D356 shape, you need to check the data and not emit the field when the source also does not exist is otherwise invalid.
It seems you're using a Foreach over the input, then creating the D365 message with a Compose Action. The thing is, the Compose Action doesn't give you much control over the output.
Instead, you should use a Liquid Transform where you can test the input before emitting any field.
Liquid - Control Flow

PowerBI Datetime filter acts like every other filter?

I'm brand new to Power BI and I'm not sure if I'm doing something wrong, but I would expect a "date/time" field would have special options for filtering. However, the filter actually lists a dropdown of all values ("2015-09-24 12:00:01", "2015-09-24 12:00:02", "2015-09-24 12:00:03", etc).
How can I filter by "last year" or "last 7 days"? Am I missing something simple?
I have tried in the web interface and Desktop.
You need to set the field's data type to Date/Time. If you're seeing strings, the most common issue is that in the query the field is defined as type "any", which gets interpreted as a string. So just go to the query window, change the data type for the affected columns, and see what happens. One little hint, is that usually after you use a function or transform (especially Add Column!) the resulting column will have the "any" data type. So double check and set the data type you really want.

optional parameter addition to a colletion (asp.net C#)

Hello friends i am to add optional parameter to pass these in a method the parameter may vary every time.
And i need to pass these parameter to a method, so my question is how should i add these optional parameter to a collection and what kind of collection object should i use and how should i use that.
i elaborate here, i am having following fields.
1)course field(a drop down list) and on selected index change of course a check box list of corresponding branches are visible now i can select branches of choice by putting check mark on check boxes.(both course and branch are compulsory fields)
2)pass_out year which is a compulsory field.(a text field)
3)education gap which is optional so the text box may be empty as well and may having a digit as well.
4)required first year percent, second year, third year, final year, current degree, high school, senior secondary, gradation, post graduation, diploma percent, birth date which are all optional so these fields may also be empty or having a digit in the text box.
5) current backlog(a drop down list)having choices all, yes , no.
6)number of ATKT text box which may also be empty or can have a digit.
So i want to store all these variables value to some collection of object which will passed to a different method by passing all these variable from here,
But i am unable to figure out how should i store these optional variable to some object and how should i pass them to other method where all variable values will be taken out and an appropriate query will be written to interact with the data base to get the data table.
please elucidate me on this please. I am really not getting a feasible solution, i have thought of few options which i can let you know if you demand but those all seems to be tedious and difficult and redundant so i see help from you.
Don't bother with optional parameters or some collection of parameters, just decide how you will represent each value best, including how to represent empty values.
For a string value you can just use a null reference or an empty string. For a numeric value you can use a nullable int (int?). For a list of checkboxes where none is selected you can send an empty list.
When figuring out how to use this in a query to the database, it's easier if you have the values as parameters that always exist even if the values represent an empty value, rather than to have to parse out parameters from a collection where a parameter might be missing. Also, as you have different data types it's better if you can use an appropriate data type for each parameter, instead of casting everything into the same mold just to fit in a collection.

Resources