Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / ​​​​​​​BPErrorTableFie...
Finance forum
Suggested answer

​​​​​​​BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.

Posted on by 188
Hi,

i created a str computed column method, that returns literal
SysComputedColumn::returnLiteral(1), SysComputedColumn::returnLiteral(0)

And i got this BP warning: BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.

1. What EDT can i use for this one to remove the BP warning, as there is no str with 1 single character -- or shall i create a new EDT?

2. if i switch the method to NoYes instead of str (as i can create enum unmapped field)-- what shall i use instead of returnLiteral(1)?
 
3. if i switch the method to boolean instead of str -- what shall i use instead of returnLiteral(1)? also there is no /boolean un mapped field to choose in the first place
  • Martin Dráb Profile Picture
    Martin Dráb 225,254 Super User on at
    ​​​​​​​BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.
    The type of the field does matter. One would create a string field and the other would create an enum field. The method will always return a string because it returns SQL code (which is a text), not the field value. The value is obtained by executing this SQL code when exporting the data.
     
    You can fill in Extends property if you're creating a specialization of an exiting EDT. If it's not the case, leave it empty.
  • CU04051814-0 Profile Picture
    CU04051814-0 188 on at
    ​​​​​​​BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.
    Hi Martin,

    So if the method return type is string, and i use returnLiteral(NoYes:Yes), then in this case it doesn't matter if I use string un-mapped field or enum un-mapped field?

    And if i will create a new EDT with string size = 1, then in this case what should the "extends" property be filled with?
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,254 Super User on at
    ​​​​​​​BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.
    1) 10 isn't the minimum string length. You can use 1 if you want.
    2) Yes, the return value of the method must be string, because it's actually a piece of SQL code.
    3) You can use enums; you're just doing it wrong. If you look at your own screenshot, you'll see Enum Unmapped Field, which is what you need to use. The method will still return a string, as discussed in the previous point. You can find many examples in the standard application, e.g. SalesOrderLineCDSV2Entity::areTotalsComputedColumnDefinition().
  • CU04051814-0 Profile Picture
    CU04051814-0 188 on at
    ​​​​​​​BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.
    Hi


    1. When you  say "Create a new one when no suitable one exists." As i said, returnLiteral(1) is only 1 single character, so shall i create a new EDT with extended dataType string10? as this is the minimum?
    or since i'm not going to use it other than here, then there is no need to create a new EDT, i can just amend the edt on the computed column to string10, then add the label to both the entity field and staging table field?
     
    2. You mean i can leave my method return type as str, but use returnLiteral(NoYes::Yes) instead of returnLiteral(NoYes::1)?
    as enums as stored as integers, and returnLiteral will convert the result to str which would still result in 0 or 1?
     
    3. I don't think I can use enums as computed columns, maybe it's a bug from microsoft, which means i can't also use booleans
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,254 Super User on at
    ​​​​​​​BPErrorTableFieldNotDefinedUsingType: Field must be defined using a type.
    1. Use a data type that correctly describes the purpose of field (Name, Label, HelpText). Create a new one when no suitable one exists.
    2. You could technically use what you already have, because NoYes is stored as 0 or 1. But returnLiteral(NoYes::Yes) and returnLiteral(NoYes::No) will be better. But make sure you use an EDT with a specific label etc., as discussed above.
    3. boolean is an enum type, therefore it's the same situation as in the previous point.

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 284,737 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,254 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans