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
14 replies
Subscribers
7 subscribers
Views
4330 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
using apply and merge on a gridtext column
garym
over 7 years ago
Hi,
I have a grid where one of the columns is supposed to be calculated based on a certain attribute value. The gridTextColumn is below. It just uses a date field called "fssIssuanceDate_datetime" and is supposed to add 4 days to the date if the market type ="F". Otherwise, add 10 days if the market type ="P". This calculation is supposed to happen in a rule that is applied to the data.
For some reason, it is always adding 10 days meaning it seems to ignore the market type="F" where there are definitely records that are equal to that. Everything looks correct to me. The constants being used are correct such as the 4 and 10 days so I don't know if it's something to do with using the apply in a gridTextColumn.
a!gridTextColumn(
label: "FSS Issued On",
field: "fssIssuanceDate_datetime",
data: if(local!datasubset.totalCount=0, {},
...
OriginalPostID-236198
Discussion posts and replies are publicly visible
0
garym
over 7 years ago
... todate(apply(rule!NOD_calculateFssForOpenNodReport,
merge(
index(local!datasubset.data, "fssIssuanceDate_datetime", {}),
index(local!datasubset.data, "crsMarketType_text", {})
)
)))
),
The code for the NOD_calculateFssForOpenNodReport is the following:
if(
rule!APN_isBlank(
ri!pssIssue_dt
),
"",
if(
ri!marketType_txt = cons!NOD_MARKET_TYPE_F,
caladddays(
ri!pssIssue_dt,
cons!NOD_FSS_CALC_DAYS_FINANCIAL
),
caladddays(
ri!pssIssue_dt,
cons!NOD_FSS_CALC_DAYS_PHYSICAL
)
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jamie Loizou
Appian Employee
over 7 years ago
@Gary, when I re-create the rules you've listed, the results are correct for me: http://screencast.com/t/KgbwMAyWM . See below for my (similar) code. Note that specifying the applied rule's attributes is an important best practice (in case the sub-rule's parameters change in the future), though it didn't affect the output in this case.
Can you please ensure that cons!NOD_MARKET_TYPE_F is not a multiple type? If it is, the IF condition isn't evaluating as-expected. If you're unable to change the constant from multiple to single, you can cast the condition to type 26 (single-value boolean).
cast(26, ri!marketType_txt = cons!NOD_MARKET_TYPE_F),
-------parent rule----------
with(
local!data: {
{date: now(), type: "F"},
{date: now(), type: "test"},
{date: now(), type: "F"}
},
todate(
apply(
rule!JML_testRule(
pssIssue_dt: _,
marketType_txt: _
),
merge(
index(
local!data,
"date",
{}
),
index(
local!data,
"type",
{}
)
)
)
)
)
-----rule!JML_testRule definition------
if(
rule!APN_isBlank(
ri!pssIssue_dt
),
"",
if(
ri!marketType_txt = "F",
caladddays(
ri!pssIssue_dt,
4
),
caladddays(
ri!pssIssue_dt,
10
)
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
garym
over 7 years ago
Hi Jamie,
Thanks for the reply. Yes I verified that the constant NOD_MARKET_TYPE_F is not set to multiple.
Does it work for you if you use constants for the "F" and 4 and 10 days? It shouldn't matter but just curious.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jamie Loizou
Appian Employee
over 7 years ago
Using constants should make no difference.
Can you please confirm that the constants have the correct values (4 and 10) as integers or decimals? Perhaps when creating from copy they both have value of 10? Could you also please list parameters when calling the sub-rule, in case the rule parameters are out of order, there is a 3rd parameter, or if they will change in the future?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
garym
over 7 years ago
I have confirmed that NOD_FSS_CALC_DAYS_FINANCIAL is 4 days and it is Number (Integer). The constant NOD_FSS_CALC_DAYS_PHYSICAL is 10 days and it is Number (Integer)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jamie Loizou
Appian Employee
over 7 years ago
Are the parameters listed when applying the rule?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
garym
over 7 years ago
data: if(local!datasubset.totalCount=0, {},
...
Loading…
4 hours ago Unstarred Open Message Comment
Comment Hide comments
Profile photo for Gary Magsano
Info Hazard
Jamie,
Can you tell me where the parameters should be listed? Let's say they are called parameterA and parameter? Do I put it before the index statements?
todate(apply(rule!NOD_calculateFssForOpenNodReport,
merge(
index(local!datasubset.data, "fssIssuanceDate_datetime", {}),
index(local!datasubset.data, "crsMarketType_text", {})
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
garym
over 7 years ago
Jamie - Disregard my last post. I found my answer in your previous post.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
garym
over 7 years ago
Still didn't work. The if statement is always evaluating to false and therefore only the second condition of adding 10 days is executing. Is it possible that it is only looking at the first element in the list and not each element in the array?
a!gridTextColumn(
label: "FSS Issued On",
field: "fssIssuanceDate_datetime",
data: if(local!datasubset.totalCount=0, {},
todate(apply(rule!NOD_calculateFssForOpenNodReport(pssIssue_dt: _,
marketType_txt:_),
merge(
index(local!datasubset.data, "fssIssuanceDate_datetime", {}),
index(local!datasubset.data, "crsMarketType_text", {})
)
)))
),
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jamie Loizou
Appian Employee
over 7 years ago
Does rule!NOD_calculateFssForOpenNodReport work correctly for you when you provide test inputs to it directly?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>