вторник, 20 ноября 2018 г.

How to decode XML string Ax 2012

Hi again! I haven't written posts recently. But today I had a task, which was unusual for me - decode XML string to readable view to parse particular value. Or decoding the XML string.
So, I got a xml node like this

<column columnName="OrderLineFieldValues">&lt;OrderLineFieldValueCollection&gt;&lt;OrderLineFieldValue&gt;&lt;OrderLineFieldSystemName&gt;Backordered&lt;/OrderLineFieldSystemName&gt;&lt;Value&gt;4&lt;/Value&gt;&lt;/OrderLineFieldValue&gt;&lt;OrderLineFieldValue&gt;&lt;OrderLineFieldSystemName&gt;CutInspect&lt;/OrderLineFieldSystemName&gt;&lt;Value&gt;&lt;/Value&gt;&lt;/OrderLineFieldValue&gt;&lt;OrderLineFieldValue&gt;&lt;OrderLineFieldSystemName&gt;Mileage&lt;/OrderLineFieldSystemName&gt;&lt;Value&gt;&lt;/Value&gt;&lt;/OrderLineFieldValue&gt;&lt;OrderLineFieldValue&gt;&lt;OrderLineFieldSystemName&gt;Notes&lt;/OrderLineFieldSystemName&gt;&lt;Value&gt;&lt;/Value&gt;&lt;/OrderLineFieldValue&gt;&lt;OrderLineFieldValue&gt;&lt;OrderLineFieldSystemName&gt;SerialNumber&lt;/OrderLineFieldSystemName&gt;&lt;Value&gt;&lt;/Value&gt;&lt;/OrderLineFieldValue&gt;&lt;/OrderLineFieldValueCollection&gt;</column>';

So, looks a little bit confused, doesn't it?

Well, from this mess I'd need to get particular values. How can I do this?  First of all, I started searching some sort of open API to do this but faced with lack of it. But after 1 hour or so I finally found the desired solution. For me it looks like this:
static void Job3(Args _args)
{
    str output;
    str input = @'my encoded XML string';
 
    output = System.Web.HttpUtility::HtmlDecode(input);
 
    info(output);
}

All that I need is in one HtmlDecode method! It's nice. Now I can continue working on the parser which could help me to get the required value from the XML node.

Hope, this piece of code would be useful for someone other as it was for me!

Happy DAXing! 

среда, 5 сентября 2018 г.

Get LogisticsLocation record from customer

Hi! 
Today I've had a requirement to show some custom fields from the LogisticsLocation record from the customer table. I wrote a display method for a particular field, but this approach can be used in different ways. It depends on your requirements.
So, below the code:

public display IsReservedAccount displayIsReservedAccount(CustTable _customer)
{
    DirParty                        dirParty;
    LogisticsLocation               location;
    LogisticsPostalAddress          address;
    dirParty = DirParty::constructFromCommon(_customer);
    address = dirParty.getPrimaryPostalAddressLocation().getPostalAddress();
    location = LogisticsLocation::find(address.Location);
    return location.IsReservedAccount;
}
Hope it will be useful for someone as for myself. 

пятница, 18 мая 2018 г.

Check how many rows were selected on the form grid

Hi!

This approach is common for either DAX 2012 or D365FO.

If you need to check how many rows were selected by the user, you just need to get the formDataSource value before, for example

FormDatasource fds = _args.record().datasource();

And then write next code:
if (fds.recordsMarked().lastIndex() > 1)
{
    info("more than 1 record was selected");
}  

Hope, this information will be useful for someone as for me.

понедельник, 12 марта 2018 г.

Disable auto complete of form control


Hi!
Today I've faced with an issue which causes some discontent of my client. He wanted to scan barcode via barcode field but without autocomplete in this field. What I mean: when you input something into the field (the field type doesn't matter), the system "remembers" this value and if you try to enter it one more time when you started to enter, the system will complete it for you. For example:
"111". When you started entering 111 second time the system will finish it for you.
And I'd need to disable this feature as my client wants. But I didn't find any property which can help me with this.
After a while, my friend suggested I use the method delAutoCompleteString() on the control.

Finally, the code for disabling autocompletion for control would look like this:
public boolean modified()
{
boolean ret;
;
ret = super();
element.delAutoCompleteString(this);
return ret;
          } 

I hope, this information will be helpful for someone else :)

Happy DAX-ing!