Skip to main content

Notifications

Finance forum
Answered

Data entity ranges

Posted on by 1,548

Hi,

1. what's the difference between putting a range on the dataSource of the entity. Or in the range node of the entity itself?

2. I have an Enum field called status in one of the dataSources that have the following names: A B C D E F

i want to export the entity by putting a range that meets the following  if (status = A or status C or Status = D or Status = F)

i think this one is easy, i should do this:
pastedimage1604581583041v1.png

comma means OR right????

3. However there is special condition for Status = F

if another field called field1 is filled then don't take Status = F. However if field1 was empty then i should take it. How can i do this?

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: Data entity ranges

    Thanks Sergie, it works now

    so it seems i should use numbers when putting a complex range. But i can use hardcoded values if it's a simple range.

    And it seems not sure, for complex ranges i can put the range on any field if the range contains more than one field?

  • Verified answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Data entity ranges

    Hi Junior AX,

    1. The range should be properly formatted (each simple condition should be wrap be own parentheses)

    (((Status == 10) && (fiedl1=="")) || (Status ==15) || (Status == 30) || (Status == 50))

    2. Computed column can be used as a range field in a data project.

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: Data entity ranges

    Hi Sergie,

    1. I tried this

    ((Status == 10 && fiedl1=="") || Status ==15 || Status == 30 || Status =50)

    where i put this range on the entity datasource "Status" field

    but i'm getting this error: (sth related to right parenthesis in 2nd screenshot)

    pastedimage1606429447244v1.pngpastedimage1606429689874v1.png

    2. Remember i created a sys computed coloumn for the condition above, where it returned 1 if the condition is met and returned 0 if not.

    And the only option was to put the range on data project = 1 because i can't do this on the entity. But u mentioned that i can do the range on code if i used advanced filtering, can you explain more? what should i do with the sys computed column i created.  (In case point 1 didn't work)

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Data entity ranges

    Hi JuniorAX,

    Could you, please, share how you tried to write range expression? I tried to simulate your case with SalesTable table and filtering by status and looks like it works, but you should use integer values for statuses instead of symbols.

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: Data entity ranges

    Hi Sergie,

    4. From what i understood, to use advanced filtering, i need to create a new static method with

    [QueryRangeFunctionAttribute()]

    but i couldn't really understand what should i put inside the method? what should i write to achieve the result  i want

    and do i need to create a computed column as well?

    4.c i tried it but it didn't work, i got about 39 errors, one of them saying field B is not found. So i'll forget about this.

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Data entity ranges

    Hi JuniorAX,

    4. On the data source level you can't add range for the computed column as the computed column itself added on the entity level. I meant if you decide to use advanced filtering, you can add in the data source.

    4.a. nope, it will not override it. It will be added as an additional range as well (Status = A and Status != A, no records as well)

    4.c. You can try to put it on data source level for status field (no sure if it works), but you need to use '&&' instead of 'and' ((Status == F && Field1 =="") || Status ==C || Status == A || Status =B))

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: Data entity ranges

    4. How? I think this should not work for computed columns, because I can't choose my computed column in ranges under dataSource and put method inside value property.

    can you explain more how can i put range of this new method i created inside entity and not on dataLevel?

    4.a but if i put range !A ,  will this override the actual entity dataSource range which is A?

    4.c  I think you are right entity ranges don't work , i just tested it and  also looked at sql view

    But what i meant is, if it worked like queries, can i put in the entity range value: something like

    ((Status == F and Field1 =="" || Status ==C || Status == A || Status =B))

    if yes how should i write it exactly?

    and what field should i specify as i'm using a combination of field1 and status

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Data entity ranges

    Hi,

    4. You can specify it on range level in code as well (for example query HcmMyGoal range CurrentWorker), but it will be a hard-coded range and you can't change it without development.

    4.a. In this case, the entity will return only records with Status A, and filters on the data project will filter on top of that (so in this case it will be A and B = no records)

    4.b. It's something you can test, as I said it didn't work for me and I didn't have time to test it.

    4.c If entity range is working in the same way as query range, then yes. If you are talking about computed column you can just put 1 as is to value property.

  • junior AX Profile Picture
    junior AX 1,548 on at
    RE: Data entity ranges

    Hi Sergie,

    I tested it and it's working thanks alot :D

    4. using advanced filtering or the sysComputedColumn, then i have to use range on data project level. I can't do it in code?

    Few questions related to your sentence

    Range on data source it's a hard-coded range that can't be changed without development. The range on entity-level doesn't work for me, but I suppose that it should work as ranges on the query: a predefined set of ranges which can be changed in a data project

    a. Range on data source it's a hard-coded range that can't be changed without development: 

    You mean if the range in dataSource query is A. Then i can't change A in data project? what if i put in data project level !A what would happen?

    also if in data project i put Status = B and dataSource range was A.... would it take is A or B   OR   A and B?

    b. The range on entity-level doesn't work for me, but I suppose that it should work as ranges on the query: a predefined set of ranges which can be changed in a data project

    Here you mean if range in entity range was A, if i try to put anything on data level project ranges, it will clear A at all. and will start looking at my new data project level or what?

    c. since entity range is the same as query range. Then i can write something hardcoded right?

    what should i put the property value exactly? how can i write it? and should i include quotations somewhere?

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: Data entity ranges

    Hi JuniorAX,

    1. Yes, you are correct.

    2. You can put a range on a data project level

    3. For incremental push it should not be an issue

    4. In this case your entity will be designed for one use case, I recommend to put a range on the data project level, and in the future, if you will need to use the same entity for a different purpose, you don't need to create a new one or change ranges.

    5. I'm not sure how much records in status D you will have, but if the number of records is not high and it's possible to delegate filtering, I would go with this approach (at least, you don't need to implement complex ranges)

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Dynamics 365 Community Newsletter - August 2024

Catch up on the latest D365 Community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,186 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 227,996 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans