Skip to main content

Notifications

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

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

editSubscribe (1) ShareShare
ReportReport
Posted on by 118
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
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 223,308 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 118 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 223,308 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

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,375 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans