on 2025 Feb 19 3:26 AM
Hi,expert!
I use annotations to control the property 'stock' of this entity, when its value is equal to 0 can be deleted, but it does not work, I check the value of not 0 in my table, still can be deleted, could you tell my code is wrong?
it is my code:
entity BooksAnalytics : managed
{
key ID : Integer
@title : 'ID';
title : String
@title : 'Title';
stock : Integer
@title : 'Stock';
category1 : String
@title : 'Category1';
category2 : String
@title : 'Category2';
publishedAt : Date
@title : 'Published At';
authors : Association to one Authors
@title : 'Author';
}......
//动态删除操作 动态表达式
annotate BooksAnalytics with @(
Capabilities.DeleteRestrictions: {
$Type: 'Capabilities.DeleteRestrictionsType',
Deletable:
{$edmJson: {$If: [{$Eq: [{$Path: 'stock'}, 0]}, true,false]}}
}
);
and there is the xml:
it still can be deleted when it’s not equal 0
Request clarification before answering.
I found a way to work around this by using CodeList's associated entity in the entity, representing the state, and then defining a Boolean field to use for the comment.
entity BooksAnalytics : managed
{
key ID : Integer
@title : 'ID';
title : String
@title : 'Title';
stock : Integer
@title : 'Stock';
BookStatus : Association to BookStatus @readonly //the new
@title : 'Stutas';
category1 : String
@title : 'Category1';
category2 : String
@title : 'Category2';
publishedAt : Date
@title : 'Published At';
authors : Association to one Authors
@title : 'Author';
}......
entity BookStatus : CodeList
{
key code : String enum {
Available = 'A';
Discontinued = 'D';
} default 'A'; //> will be used for foreign keys as well
insertDeleteRestriction: Boolean; // = NOT createDeleteHidden
}......
//动态删除操作 动态表达式
annotate BooksAnalytics with @(
Capabilities.DeleteRestrictions: {
$Type: 'Capabilities.DeleteRestrictionsType',
Deletable: BookStatus.insertDeleteRestriction
}
);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.