Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
5 replies
Subscribers
7 subscribers
Views
2822 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
How do I determine if a column name exists in an array or datasubset?
jayanthik
over 9 years ago
How do I determine if a column name exists in an array or datasubset?
Say for example, the below expression when executed returns that datasubset has two fields /columns names - firstName and secondName. I want to find out if any string "xyz" is present as a field or column in a datasubset /array.
todatasubset({
type!Column(field: "username", alias: "un", visible: true),
type!Column(field: "firstName", alias: "first", visible: false),
type!Column(field: "lastName", alias: "last", visible: true)
},
a!pagingInfo(startIndex: 1, batchSize: 2, sort:{field: "alias", ascending: true})
)
.data
when executed returns the below result
[field=firstName, alias=first, visible=false], [field=lastName, alias=last, visible=true]
OriginalPostID-152071
OriginalPostID-152071
Discussion posts and replies are publicly visible
Parents
0
judyg
over 9 years ago
What about using fn!contains(array, value)? See the below test code.
= load(
local!datasubset: todatasubset(
{
type!Column(
field: "username",
alias: "un",
visible: true
),
type!Column(
field: "firstName",
alias: "first",
visible: false
),
type!Column(
field: "lastName",
alias: "last",
visible: true
)
},
a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: {
field: "alias",
ascending: false
}
)
).data,
{
a!textField(
label: "Test column exists or not",
value: if(fn!contains(local!datasubset.field,"lastName"),
"The column exists",
"The column is missing"),
readOnly: true
),
a!textField(
label: "all columns",
value: local!datasubset.field,
readOnly: true
)
}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
judyg
over 9 years ago
What about using fn!contains(array, value)? See the below test code.
= load(
local!datasubset: todatasubset(
{
type!Column(
field: "username",
alias: "un",
visible: true
),
type!Column(
field: "firstName",
alias: "first",
visible: false
),
type!Column(
field: "lastName",
alias: "last",
visible: true
)
},
a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: {
field: "alias",
ascending: false
}
)
).data,
{
a!textField(
label: "Test column exists or not",
value: if(fn!contains(local!datasubset.field,"lastName"),
"The column exists",
"The column is missing"),
readOnly: true
),
a!textField(
label: "all columns",
value: local!datasubset.field,
readOnly: true
)
}
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data